~ubuntu-branches/debian/jessie/stellarium/jessie

« back to all changes in this revision

Viewing changes to src/StelModuleMgr.hpp

Tags: upstream-0.9.1
Import upstream version 0.9.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#ifndef STELMODULEMGR_H
21
21
#define STELMODULEMGR_H
22
22
 
23
 
#include <boost/iterator/iterator_facade.hpp>
 
23
#include <QObject>
 
24
#include <QMap>
 
25
#include <QList>
24
26
#include "StelModule.hpp"
25
27
 
26
 
//! @brief Manage a collection of StelModule
27
 
//! @author Fabien Chereau <stellarium@free.fr>
28
 
class StelModuleMgr{
 
28
//! @class StelModuleMgr
 
29
//! Manage a collection of StelModules including both core and plugin modules.
 
30
//! 
 
31
class StelModuleMgr : public QObject
 
32
{
 
33
        Q_OBJECT
 
34
                        
29
35
public:
30
 
        
31
36
        StelModuleMgr();
32
 
    ~StelModuleMgr();
 
37
        ~StelModuleMgr();
33
38
        
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);
42
47
 
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);
 
50
        
 
51
        //! Get the list of all the currently registered modules
 
52
        QList<StelModule*> getAllModules() {return modules.values();}
45
53
        
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();
49
57
 
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)
52
60
        {
53
61
                return callOrders[action];
54
62
        }
55
63
 
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>
58
 
        {
59
 
         public:
60
 
            Iterator() : mapIter() {}
61
 
         private:
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; }
66
 
        
67
 
            bool equal(Iterator const& other) const
68
 
            {
69
 
                return this->mapIter == other.mapIter;
70
 
            }
71
 
        
72
 
            StelModule*& dereference() const { return mapIter->second; }
73
 
        
74
 
            std::map<std::string, StelModule*>::iterator mapIter;
75
 
        };
76
 
 
77
 
   Iterator begin()
78
 
   {
79
 
      return Iterator(modules.begin());
80
 
   }
81
 
 
82
 
   const Iterator& end()
83
 
   {
84
 
      return endIter;
85
 
   }
 
64
        //! Contains the information read from the module.ini file
 
65
        struct ExternalStelModuleDescriptor
 
66
        {
 
67
                //! The name of the directory and of the lib*.so with *=key
 
68
                QString key;
 
69
                QString name;
 
70
                QString author;
 
71
                QString contact;
 
72
                QString description;
 
73
                bool loadAtStartup;
 
74
        };
 
75
 
 
76
        //! Return the list of all the external module found in the modules directories
 
77
        static QList<ExternalStelModuleDescriptor> getExternalModuleList();
 
78
 
 
79
        //! Enum used when selecting objects to define whether to add to, replace, or remove from 
 
80
        //! the existing selection list.
 
81
        enum selectAction
 
82
        {
 
83
                ADD_TO_SELECTION,
 
84
                REPLACE_SELECTION,
 
85
                REMOVE_FROM_SELECTION
 
86
        };
 
87
 
 
88
 
86
89
private:
87
 
        
88
90
        //! The main module list associating name:pointer
89
 
        std::map<std::string, StelModule*> modules;
 
91
        QMap<QString, StelModule*> modules;
90
92
        
91
93
        //! The list of all module in the correct order for each action
92
 
        std::map<std::string, std::vector<StelModule*> > callOrders;
93
 
        
94
 
        const Iterator endIter;
 
94
        QMap<StelModule::StelModuleActionName, QList<StelModule*> > callOrders;
 
95
 
95
96
};
96
97
 
97
98
#endif