/* core/loader.h This file is part of the Osirion project and is distributed under the terms of the GNU General Public License version 2 */ #ifndef __INCLUDED_CORE_LOADER_H__ #define __INCLUDED_CORE_LOADER_H__ #include #include "core/module.h" namespace core { /// module factory registry /** The Loader contains a list of module factories and can load * the desired module on request */ class Loader { public: /// function pointer type for a module factory typedef Module *(* FactoryFuncPtr)(); /// find a registered mmodule factory static FactoryFuncPtr find(const char *label); /// find a registered module factory static FactoryFuncPtr find(const std::string &label); /// add a factory to the loader registry static void add(const std::string & label, FactoryFuncPtr factory); /// assign the next module to init static bool load(const char *label); /// assign the next module to init static bool load(const std::string &label); static inline const std::string &label() { return loader_label; } /// initialize a game module static Module *init(); /// list registered modules static void list(); /// clear the loader registry static void clear(); private: typedef std::map Registry; static Registry loader_registry; static std::string loader_label; }; } #endif // __INCLUDED_CORE_LOADER_H__