20
20
#ifndef STELMODULEMGR_H
21
21
#define STELMODULEMGR_H
23
#include <boost/iterator/iterator_facade.hpp>
24
26
#include "StelModule.hpp"
26
//! @brief Manage a collection of StelModule
27
//! @author Fabien Chereau <stellarium@free.fr>
28
//! @class StelModuleMgr
29
//! Manage a collection of StelModules including both core and plugin modules.
31
class StelModuleMgr : public QObject
34
39
//! Register a new StelModule to the list
35
40
void registerModule(StelModule* m);
38
43
//! @param moduleID the name of the module = name of the dynamic library file without extension
39
44
//! (e.g "mymodule" for mymodule.so or mymodule.dll)
40
45
//! @return the loaded module or NULL in case of error. The returned Stelmodule still needs to be initialized
41
StelModule* loadExternalPlugin(const std::string& moduleID);
46
StelModule* loadExternalPlugin(const QString& moduleID);
43
48
//! Get the corresponding module or NULL if can't find it.
44
StelModule* getModule(const std::string& moduleID);
49
StelModule* getModule(const QString& moduleID);
51
//! Get the list of all the currently registered modules
52
QList<StelModule*> getAllModules() {return modules.values();}
46
54
//! Generate properly sorted calling lists for each action (e,g, draw, update)
47
55
//! according to modules orders dependencies
48
56
void generateCallingLists();
50
58
//! Get the list of modules in the correct order for calling the given action
51
const std::vector<StelModule*>& getCallOrders(const std::string& action)
59
const QList<StelModule*>& getCallOrders(StelModule::StelModuleActionName action)
53
61
return callOrders[action];
56
//! Add iterator so that we can easily iterate through registered modules
57
class Iterator : public boost::iterator_facade<Iterator, StelModule*, boost::forward_traversal_tag>
60
Iterator() : mapIter() {}
62
friend class boost::iterator_core_access;
63
friend class StelModuleMgr;
64
Iterator(std::map<std::string, StelModule*>::iterator p) : mapIter(p) {}
65
void increment() { ++mapIter; }
67
bool equal(Iterator const& other) const
69
return this->mapIter == other.mapIter;
72
StelModule*& dereference() const { return mapIter->second; }
74
std::map<std::string, StelModule*>::iterator mapIter;
79
return Iterator(modules.begin());
64
//! Contains the information read from the module.ini file
65
struct ExternalStelModuleDescriptor
67
//! The name of the directory and of the lib*.so with *=key
76
//! Return the list of all the external module found in the modules directories
77
static QList<ExternalStelModuleDescriptor> getExternalModuleList();
79
//! Enum used when selecting objects to define whether to add to, replace, or remove from
80
//! the existing selection list.
88
90
//! The main module list associating name:pointer
89
std::map<std::string, StelModule*> modules;
91
QMap<QString, StelModule*> modules;
91
93
//! The list of all module in the correct order for each action
92
std::map<std::string, std::vector<StelModule*> > callOrders;
94
const Iterator endIter;
94
QMap<StelModule::StelModuleActionName, QList<StelModule*> > callOrders;