Evoplex  0.2.1
plugininterface.h
1 /* Evoplex <https://evoplex.org>
2  * Copyright (C) 2016-present - Marcos Cardinot <marcos@cardinot.net>
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef PLUGININTERFACE_H
18 #define PLUGININTERFACE_H
19 
20 #include <QObject>
21 #include <QtPlugin>
22 
23 #include "abstractgraph.h"
24 #include "abstractmodel.h"
25 
26 namespace evoplex {
27 
32 {
33 public:
35  virtual ~PluginInterface() = default;
36 
38  virtual AbstractPlugin* create() = 0;
39 };
40 }
41 
42 Q_DECLARE_INTERFACE(evoplex::PluginInterface, "org.evoplex.PluginInterface")
43 
44 #define REGISTER_PLUGIN(CLASSNAME) \
45  namespace evoplex { \
46  class PG_##CLASSNAME : public QObject, public PluginInterface \
47  { \
48  Q_OBJECT \
49  Q_PLUGIN_METADATA(IID "org.evoplex.PluginInterface" \
50  FILE "metadata.json") \
51  Q_INTERFACES(evoplex::PluginInterface) \
52  public: \
53  AbstractPlugin* create() { return new CLASSNAME(); } \
54  };}
55 
56 #endif // PLUGININTERFACE_H
A common interface for plugins.
Definition: plugininterface.h:31
virtual AbstractPlugin * create()=0
Creates a model/graph object.
Base class for plugins.
Definition: abstractplugin.h:34
Definition: abstractgraph.h:29
virtual ~PluginInterface()=default
Provides the destructor to keep compilers happy.