Merge branch 'ryzom/rites' into main/gingo-test
[ryzomcore.git] / studio / src / extension_system / iplugin.h
blob01f337df1dd628ff4d614a3c91b28aa61412a613
1 // Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010-2011 Dzmitry KAMIAHIN (dnk-88) <dnk-88@tut.by>
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2010 Winch Gate Property Limited
6 //
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef IPLUGIN_H
21 #define IPLUGIN_H
23 #include <QtCore/QtPlugin>
24 #include <QtCore/QString>
25 #include <QtCore/QStringList>
27 #include "iplugin_manager.h"
29 namespace NLMISC
31 class INelContext;
34 namespace ExtensionSystem
37 /**
38 @interface IPlugin
39 @brief Base class for all plugins.
40 @details The IPlugin class is an abstract class that must be implemented
41 once for each plugin. The IPlugin implementation must be exported and
42 made known to Qt's plugin system via the Q_EXPORT_PLUGIN macro,
43 see the Qt documentation for details on that.
45 class IPlugin
47 public:
48 virtual ~IPlugin() {}
50 /**
51 @brief Called after the plugin has been loaded and the IPlugin instance has been created.
53 @details The initialize methods of plugins that depend
54 on this plugin are called after the initialize method of this plugin
55 has been called. Plugins should initialize their internal state in this
56 method. Returns if initialization of successful. If it wasn't successful,
57 the \a errorString should be set to a user-readable message
58 describing the reason.
60 virtual bool initialize(IPluginManager *pluginManager, QString *errorString) = 0;
62 /**
63 @brief Called after the IPlugin::initialize() method has been called,
64 and after both the IPlugin::initialize() and IPlugin::extensionsInitialized()
65 methods of plugins that depend on this plugin have been called.
67 @details In this method, the plugin can assume that plugins that depend on
68 this plugin are fully 'up and running'. It is a good place to
69 look in the plugin manager's object pool for objects that have
70 been provided by dependent plugins.
72 virtual void extensionsInitialized() = 0;
74 /**
75 @brief Called during a shutdown sequence in the same order as initialization
76 before the plugins get deleted in reverse order.
78 @details This method should be used to disconnect from other plugins,
79 hide all UI, and optimize shutdown in general.
81 virtual void shutdown() { }
83 /**
84 @brief This method should be implemented to work properly NeL singletons.
85 Called immediately after loading the plugin.
86 @code
87 void Plugin::setNelContext(NLMISC::INelContext *nelContext)
89 #ifdef NL_OS_WINDOWS
90 // Ensure that a context doesn't exist yet.
91 // This only applies to platforms without PIC, e.g. Windows.
92 nlassert(!NLMISC::INelContext::isContextInitialised());
93 #endif // NL_OS_WINDOWS
94 _LibContext = new NLMISC::CLibraryContext(*nelContext);
96 @endcode
98 virtual void setNelContext(NLMISC::INelContext *nelContext) = 0;
101 }; //namespace ExtensionSystem
103 Q_DECLARE_INTERFACE(ExtensionSystem::IPlugin, "dev.ryzom.com.ObjectViewerQt.IPlugin/0.9.2")
105 #endif // IPLUGIN_H