diff options
Diffstat (limited to 'server/include/api_module_base.h')
-rw-r--r-- | server/include/api_module_base.h | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/server/include/api_module_base.h b/server/include/api_module_base.h index 89fc4dd..d8acf9b 100644 --- a/server/include/api_module_base.h +++ b/server/include/api_module_base.h @@ -21,25 +21,35 @@ #ifndef API_MODULE_BASE_H_INCLUDED #define API_MODULE_BASE_H_INCLUDED -#include <api_core.h> +#include "api_core.h" +#include "settings.h" #include <boost/function.hpp> -struct module_info + + +struct module_info_base { std::string name, description, version; //module name must be set and must be unique, description and version is optional - std::map<std::string, std::string> default_settings; //set all settings supported by module here with default values to save in config for editing later + std::map<std::string, setting_s> default_settings; //set all settings supported by module here with default values to save in config for editing later boost::function<void()> on_modules_loaded; //if set, this function will be called after basic initialization of all installed modules, so installed modules can be partially used here, for example metadata storage will be available }; + + class module_base { public: virtual void load(core_api *a) = 0; - virtual const module_info &get_module_info() = 0; - virtual void set_module_settings(const std::map<std::string, std::string> &settings) = 0; //will called with settings stored in config + virtual const module_info_base &get_module_info() = 0; + virtual void set_module_settings(const std::map<std::string, setting_s> &settings) = 0; //will called with settings stored in config + virtual std::map<std::string, setting_s> &get_runtime_module_settings() //get runtime module_settings, works faster than core_api function + { + return settings; + } virtual ~module_base() = 0; protected: - std::map<std::string, std::string> settings; + std::map<std::string, setting_s> settings; + core_api *api = nullptr; }; |