X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/641204dfbdb9fc870cdd2e7f9e3169a44693e7bf..be1b46cc784e43cd28c5521bdcde79bd7463fb40:/projects/stargazer/plugin_runner.h?ds=inline diff --git a/projects/stargazer/plugin_runner.h b/projects/stargazer/plugin_runner.h index 2889300d..1c8bf422 100644 --- a/projects/stargazer/plugin_runner.h +++ b/projects/stargazer/plugin_runner.h @@ -16,80 +16,81 @@ /* * Author : Boris Mikhailenko + * Author : Maxim Mamontov */ -/* - $Revision: 1.13 $ - $Date: 2010/03/04 12:22:41 $ - $Author: faust $ - */ +#pragma once + +#include "stg/plugin.h" -#ifndef PLUGIN_RUNNER_H -#define PLUGIN_RUNNER_H -#include #include +#include +#include -#include "base_plugin.h" -#include "base_settings.h" -#include "traffcounter.h" -#include "tariffs.h" -#include "admins.h" -#include "users.h" +namespace STG +{ + +struct ModuleSettings; +struct Settings; +struct Admins; +struct Tariffs; +struct Users; +struct Services; +struct Corporations; +struct TraffCounter; +struct Store; -using namespace std; //----------------------------------------------------------------------------- -class PLUGIN_RUNNER -{ +class PluginRunner { public: - PLUGIN_RUNNER(const string & pluginFileName, - const MODULE_SETTINGS & ms, - ADMINS * admins, - TARIFFS * tariffs, - USERS * users, - TRAFFCOUNTER * tc, - BASE_STORE * store, - const SETTINGS * s); - PLUGIN_RUNNER(const PLUGIN_RUNNER & rvalue); - ~PLUGIN_RUNNER(); - - PLUGIN_RUNNER & operator=(const PLUGIN_RUNNER & rvalue); + struct Error : public std::runtime_error { + explicit Error(const std::string & msg) : runtime_error(msg) {} + }; + + PluginRunner(const std::string& pluginFileName, + const std::string& pluginName, + const ModuleSettings& ms, + Admins& admins, + Tariffs& tariffs, + Users& users, + Services& services, + Corporations& corporations, + TraffCounter& traffcounter, + Store& store, + const Settings & settings); + ~PluginRunner(); int Start(); int Stop(); - int Reload(); + int Reload(const ModuleSettings& ms); int Restart(); - bool IsRunning(); + bool IsRunning() { return m_plugin.IsRunning(); } - const string & GetStrError() const; - BASE_PLUGIN * GetPlugin(); - const string & GetFileName() const { return pluginFileName; }; + const std::string& GetStrError() const { return errorStr; } + Plugin& GetPlugin() { return m_plugin; } + const std::string& GetFileName() const { return pluginFileName; } + const std::string& GetName() const { return pluginName; } - int Load(); - int Unload(); - - uint16_t GetStartPosition() const; - uint16_t GetStopPosition() const; + uint16_t GetStartPosition() const { return m_plugin.GetStartPosition(); } + uint16_t GetStopPosition() const { return m_plugin.GetStopPosition(); } private: - string pluginFileName; - string pluginSettingFileName; - - BASE_PLUGIN * plugin; - int isPluginLoaded; - string errorStr; - - void * libHandle; - bool isRunning; - - ADMINS * admins; - TARIFFS * tariffs; - USERS * users; - BASE_STORE * store; - TRAFFCOUNTER * traffCnt; - const SETTINGS * stgSettings; - MODULE_SETTINGS modSettings; + Plugin & load(const ModuleSettings& ms, + Admins& admins, + Tariffs& tariffs, + Users& users, + Services& services, + Corporations& corporations, + TraffCounter& traffcounter, + Store& store, + const Settings& settings); + + std::string pluginFileName; + std::string pluginName; + void* libHandle; + + Plugin& m_plugin; + std::string errorStr; }; //----------------------------------------------------------------------------- -#endif //PLUGIN_RUNNER_H - - +}