00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _STELMODULEMGR_HPP_
00021 #define _STELMODULEMGR_HPP_
00022
00023 #include <QObject>
00024 #include <QMap>
00025 #include <QList>
00026 #include "StelModule.hpp"
00027 #include "StelPluginInterface.hpp"
00028
00031 #define GETSTELMODULE( m ) (( m *)StelApp::getInstance().getModuleMgr().getModule( #m ))
00032
00036 class StelModuleMgr : public QObject
00037 {
00038 Q_OBJECT
00039
00040 public:
00041 StelModuleMgr();
00042 ~StelModuleMgr();
00043
00045 void update();
00046
00049 void registerModule(StelModule* m, bool generateCallingLists=false);
00050
00054 void unloadModule(const QString& moduleID, bool alsoDelete=true);
00055
00060 StelModule* loadPlugin(const QString& moduleID);
00061
00063 void unloadAllPlugins();
00064
00067 void setPluginLoadAtStartup(const QString& key, bool b);
00068
00071 StelModule* getModule(const QString& moduleID, bool noWarning=false);
00072
00074 QList<StelModule*> getAllModules() {return modules.values();}
00075
00077 const QList<StelModule*>& getCallOrders(StelModule::StelModuleActionName action)
00078 {
00079 return callOrders[action];
00080 }
00081
00083 struct PluginDescriptor
00084 {
00085 PluginDescriptor() : loadAtStartup(false), loaded(false) {;}
00087 StelPluginInfo info;
00089 bool loadAtStartup;
00091 bool loaded;
00092
00093 private:
00094 friend class StelModuleMgr;
00095 StelPluginInterface* pluginInterface;
00096 };
00097
00099 QList<PluginDescriptor> getPluginsList();
00100
00101 private:
00104 void generateCallingLists();
00105
00107 QMap<QString, StelModule*> modules;
00108
00110 QMap<StelModule::StelModuleActionName, QList<StelModule*> > callOrders;
00111
00113 bool callingListsToRegenerate;
00114
00115 QMap<QString, StelModuleMgr::PluginDescriptor> pluginDescriptorList;
00116 bool pluginDescriptorListLoaded;
00117 };
00118
00119 #endif // _STELMODULEMGR_HPP_