From 992674362c5f64bdb8e1942eeaa7612524529cd6 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Sun, 26 May 2013 19:44:13 +0200 Subject: Automatically register ServiceProviders created by modules --- include/modules.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'include/modules.h') diff --git a/include/modules.h b/include/modules.h index 1d9d16f26..e8f0d10fe 100644 --- a/include/modules.h +++ b/include/modules.h @@ -1168,6 +1168,9 @@ typedef IntModuleList::iterator EventHandlerIter; */ class CoreExport ModuleManager { + public: + typedef std::vector ServiceList; + private: /** Holds a string describing the last module error to occur */ @@ -1189,7 +1192,7 @@ class CoreExport ModuleManager /** Loads all core modules (cmd_*) */ - void LoadCoreModules(); + void LoadCoreModules(std::map& servicemap); /** Calls the Prioritize() method in all loaded modules * @return True if all went well, false if a dependency loop was detected @@ -1207,6 +1210,16 @@ class CoreExport ModuleManager /** List of data services keyed by name */ std::multimap DataProviders; + /** A list of ServiceProviders waiting to be registered. + * Non-NULL when constructing a Module, NULL otherwise. + * When non-NULL ServiceProviders add themselves to this list on creation and the core + * automatically registers them (that is, call AddService()) after the Module is constructed, + * and before Module::init() is called. + * If a service is created after the construction of the Module (for example in init()) it + * has to be registered manually. + */ + ServiceList* NewServices; + /** Simple, bog-standard, boring constructor. */ ModuleManager(); @@ -1328,6 +1341,11 @@ class CoreExport ModuleManager /** Unregister a service provided by a module */ void DelService(ServiceProvider&); + /** Register all services in a given ServiceList + * @param list The list containing the services to register + */ + void AddServices(const ServiceList& list); + inline void AddServices(ServiceProvider** list, int count) { for(int i=0; i < count; i++) -- cgit v1.2.3