Stellarium 0.12.4
StelModuleMgr.hpp
1 /*
2  * Stellarium
3  * Copyright (C) 2006 Fabien Chereau
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
18  */
19 
20 #ifndef _STELMODULEMGR_HPP_
21 #define _STELMODULEMGR_HPP_
22 
23 #include <QObject>
24 #include <QMap>
25 #include <QList>
26 #include "StelModule.hpp"
27 #include "StelPluginInterface.hpp"
28 
31 #define GETSTELMODULE( m ) (( m *)StelApp::getInstance().getModuleMgr().getModule( #m ))
32 
36 class StelModuleMgr : public QObject
37 {
38  Q_OBJECT
39 
40 public:
41  StelModuleMgr();
42  ~StelModuleMgr();
43 
45  void update();
46 
49  void registerModule(StelModule* m, bool generateCallingLists=false);
50 
54  void unloadModule(const QString& moduleID, bool alsoDelete=true);
55 
60  StelModule* loadPlugin(const QString& moduleID);
61 
63  void unloadAllPlugins();
64 
68  void setPluginLoadAtStartup(const QString& key, bool b);
69 
73  StelModule* getModule(const QString& moduleID, bool noWarning=false);
74 
76  QList<StelModule*> getAllModules() {return modules.values();}
77 
79  const QList<StelModule*>& getCallOrders(StelModule::StelModuleActionName action)
80  {
81  return callOrders[action];
82  }
83 
86  {
87  PluginDescriptor() : loadAtStartup(false), loaded(false) {;}
93  bool loaded;
94 
95  private:
96  friend class StelModuleMgr;
97  StelPluginInterface* pluginInterface;
98  };
99 
101  QList<PluginDescriptor> getPluginsList();
102 
103 private:
106  void generateCallingLists();
107 
109  QMap<QString, StelModule*> modules;
110 
112  QMap<StelModule::StelModuleActionName, QList<StelModule*> > callOrders;
113 
115  bool callingListsToRegenerate;
116 
117  QMap<QString, StelModuleMgr::PluginDescriptor> pluginDescriptorList;
118  bool pluginDescriptorListLoaded;
119 };
120 
121 #endif // _STELMODULEMGR_HPP_