diff options
author | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2015-08-28 21:21:02 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2015-08-28 21:21:02 +0300 |
commit | 6f3f670abe3d2d78a13cd3862e3a587dd4fe4e85 (patch) | |
tree | 0d681fd23bf2e70e385d053aee1e54dbe08668b1 /server/include/api_module_base.h | |
parent | ba8247eaf522e8a129b7fbbf09a6fab010746e3a (diff) |
protocol:
typo fix
added description to setting_info
server:
api:
using structure with setting info instead of hust string for just value (a bit of necessary complication)
renamed few structs to avoid collision with protobuf ones
defined few module variables in api itself (a bit of simplification for module developer)
modules:
adapted to api changes
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; }; |