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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, 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 
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_

Generated on Mon Mar 22 09:55:37 2010 for Stellarium by  doxygen 1.5.5