Stellarium 0.11.4
Home · All Namespaces · All Classes · Functions · Coding Style · Scripting · Plugins · File Structure

core/StelModuleMgr.hpp

00001 /*
00002  * Stellarium
00003  * Copyright (C) 2006 Fabien Chereau
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.
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 
00068     void setPluginLoadAtStartup(const QString& key, bool b);
00069 
00073     StelModule* getModule(const QString& moduleID, bool noWarning=false);
00074 
00076     QList<StelModule*> getAllModules() {return modules.values();}
00077 
00079     const QList<StelModule*>& getCallOrders(StelModule::StelModuleActionName action)
00080     {
00081         return callOrders[action];
00082     }
00083 
00085     struct PluginDescriptor
00086     {
00087         PluginDescriptor() : loadAtStartup(false), loaded(false) {;}
00089         StelPluginInfo info;
00091         bool loadAtStartup;
00093         bool loaded;
00094 
00095     private:
00096         friend class StelModuleMgr;
00097         StelPluginInterface* pluginInterface;
00098     };
00099 
00101     QList<PluginDescriptor> getPluginsList();
00102 
00103 private:
00106     void generateCallingLists();
00107 
00109     QMap<QString, StelModule*> modules;
00110 
00112     QMap<StelModule::StelModuleActionName, QList<StelModule*> > callOrders;
00113 
00115     bool callingListsToRegenerate;
00116 
00117     QMap<QString, StelModuleMgr::PluginDescriptor> pluginDescriptorList;
00118     bool pluginDescriptorListLoaded;
00119 };
00120 
00121 #endif // _STELMODULEMGR_HPP_
Generated on Sat Aug 25 22:13:29 2012 for Stellarium by  doxygen 1.6.3