diff options
author | Stijn Buys <ingar@osirion.org> | 2008-11-23 12:34:07 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-11-23 12:34:07 +0000 |
commit | 583ec3285c41e9d253c4aaabd2af4dadac75f3a7 (patch) | |
tree | 5ec345e44af9d3699a95f493d8358ee766e23330 /src/core/module.h | |
parent | 44158ccfbe943b832c0e0bf9ce547212aa6c2b8b (diff) |
clean module consturction/destruction
Diffstat (limited to 'src/core/module.h')
-rw-r--r-- | src/core/module.h | 58 |
1 files changed, 7 insertions, 51 deletions
diff --git a/src/core/module.h b/src/core/module.h index 64b41bd..240488f 100644 --- a/src/core/module.h +++ b/src/core/module.h @@ -13,11 +13,11 @@ namespace core { -// a loadable game module +/// abstract base class for a game module class Module { public: - Module(const char *label, const char *name, bool interactive=true); + Module(const char *name, bool interactive=true); virtual ~Module(); /*----- inspectors ------------------------------------------------ */ @@ -38,12 +38,6 @@ public: /*----- mutators -------------------------------------------------- */ - /// run the game module - void run(); - - /// terminate a running game module - void terminate(); - /// run one timeframe virtual void frame(float seconds) = 0; @@ -53,61 +47,23 @@ public: /// is called when a player disconnects virtual void player_disconnect(Player *player) = 0; -/*----- static ---------------------------------------------------- */ - - typedef std::map<std::string, Module *> Registry; - - /// find a registered game module - static Module *find(const char *label); - - /// find a registered game module - static Module *find(const std::string &label); - - /// register a game module - static Module *add(Module *module); - - /// load a registered game module - static Module *load(const char *label); - - /// list modules - static void list(); - - /// unload all modules - static void clear(); + /// set the module label + void set_label(const std::string &label); - /// currently active module - static inline Module *active() { return module_active; } - - /// currently loaded module - static inline Module *loaded() { return module_preload; } - - /// module registry - static inline Registry & registry() { return module_registry; } + static inline Module *instance() { return module_instance; } protected: - - /// initialize the game module - virtual void init() = 0; - - /// shutdown the game module - virtual void shutdown() = 0; - /// abort a running module void abort(); private: - bool module_interactive; bool module_running; std::string module_label; - std::string module_name; - - static Registry module_registry; + std::string module_name; - static Module *module_preload; - static Module *module_active; - + static Module* module_instance; }; } |