]> vaikene.ee Git - evaf/blob - src/libs/Plugins/iplugin.h
Added Qt plugin macros to Plugins::iPlugin and Plugins::iPluginFactory for proper...
[evaf] / src / libs / Plugins / iplugin.h
1 /**
2 * @file Plugins/iplugin.h
3 * @brief Common interface for all the eVaf modules
4 * @author Enar Vaikene
5 *
6 * Copyright (c) 2011 Enar Vaikene
7 *
8 * This file is part of the eVaf C++ cross-platform application development framework.
9 *
10 * This file can be used under the terms of the GNU General Public License
11 * version 3.0 as published by the Free Software Foundation and appearing in
12 * the file LICENSE included in the packaging of this file. Please review the
13 * the following information to ensure the GNU General Public License version
14 * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
15 *
16 * Alternatively, this file may be used in accordance with the Commercial License
17 * Agreement provided with the Software.
18 */
19
20 #ifndef __PLUGINS_IPLUGIN_H
21 #define __PLUGINS_IPLUGIN_H
22
23 #include "libplugins.h"
24
25 #include <QObject>
26 #include <QString>
27
28 namespace eVaf {
29 namespace Plugins {
30
31 /**
32 * Common interface for all the eVaf modules.
33 *
34 * @code#include <Plugins/iPlugin>@endcode
35 *
36 * The iPlugin interface is the common interface implemented by all the eVaf modules.
37 */
38 class PLUGINS_EXPORT iPlugin : public QObject
39 {
40 Q_OBJECT
41
42 public:
43
44 /// Empty constructor
45 iPlugin() : QObject() {}
46
47 /// Empty virtual destructor
48 virtual ~iPlugin() {}
49
50 /**
51 * Initializes the module that implements the iPlugin interface
52 * @param args Arguments for the initialization
53 * @return True if ok; false if initialization failed
54 *
55 * The plugin manager calls the init() function for every eVaf module during the initialization
56 * of the application. Modules implementing the iPlugin interface shall allocate and initialize
57 * all the required resources in the init() function.
58 *
59 * Modules can assume that the init() function is always called once after loading the module
60 * and creating the interface object. Every init() function call is followed by a done()
61 * function call during the finalization of the application. Modules can be initialized
62 * multiple times without destroying the interface object, but init() function calls are
63 * always followed by a done() function call.
64 *
65 * When the init() function returns true, then the initialization of the module shall be completed
66 * and all the interfaces and other resources published by the module safe to use.
67 *
68 */
69 virtual bool init(const QString & args) = 0;
70
71 /**
72 * Finalizes the module.
73 *
74 * The plugin manager calls the done() function for every eVaf module during the finalization
75 * of the application. Modules implementing the iPlugin interface shall finalize and release
76 * all the resources in the done() function.
77 */
78 virtual void done() = 0;
79
80 /**
81 * Ready flag.
82 * @return True if the module is ready.
83 *
84 * The ready flag indicates that the module is initialized and all the published interfaces
85 * and resources safe to use.
86 */
87 virtual bool isReady() const = 0;
88
89 };
90
91 } // namespace eVaf::Plugins
92 } // namespace eVaf
93
94 Q_DECLARE_INTERFACE(eVaf::Plugins::iPlugin, "eVaf.Plugins.iPlugin/1.0")
95
96 #endif // iplugin.h