From: Maxim Mamontov Date: Sat, 13 Aug 2011 16:42:30 +0000 (+0300) Subject: Set services and corps to plugins X-Git-Tag: 2.408-alpha~25 X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/7b66bdcccfa4aad5a8e4110bf4769bc13c15dcfd?ds=sidebyside;hp=cbc0dcab9b85503926c58e82933a6148e81115f5 Set services and corps to plugins --- diff --git a/include/stg/corporations.h b/include/stg/corporations.h index ad23967e..88c1e8bd 100644 --- a/include/stg/corporations.h +++ b/include/stg/corporations.h @@ -25,13 +25,15 @@ #include "corp_conf.h" +class ADMIN; + class CORPORATIONS { public: - virtual int Add(const CORP_CONF & corp) = 0; - virtual int Del(const std::string & name) = 0; - virtual int Change(const CORP_CONF & corp) = 0; - virtual bool FindCorp(const std::string & name, CORP_CONF & corp) = 0; - virtual bool CorpExists(const std::string & name) const = 0; + virtual int Add(const CORP_CONF & corp, const ADMIN * admin) = 0; + virtual int Del(const std::string & name, const ADMIN * admin) = 0; + virtual int Change(const CORP_CONF & corp, const ADMIN * admin) = 0; + virtual bool Find(const std::string & name, CORP_CONF * corp) = 0; + virtual bool Exists(const std::string & name) const = 0; virtual const std::string & GetStrError() const = 0; virtual size_t Count() const = 0; diff --git a/include/stg/services.h b/include/stg/services.h index 131e2b55..5ff7a1a8 100644 --- a/include/stg/services.h +++ b/include/stg/services.h @@ -25,13 +25,15 @@ #include "service_conf.h" +class ADMIN; + class SERVICES { public: - virtual int Add(const SERVICE_CONF & service) = 0; - virtual int Del(const std::string & name) = 0; - virtual int Change(const SERVICE_CONF & service) = 0; - virtual bool FindService(const std::string & name, SERVICE_CONF & service) = 0; - virtual bool ServiceExists(const std::string & name) const = 0; + virtual int Add(const SERVICE_CONF & service, const ADMIN * admin) = 0; + virtual int Del(const std::string & name, const ADMIN * admin) = 0; + virtual int Change(const SERVICE_CONF & service, const ADMIN * admin) = 0; + virtual bool Find(const std::string & name, SERVICE_CONF * service) = 0; + virtual bool Exists(const std::string & name) const = 0; virtual const std::string & GetStrError() const = 0; virtual size_t Count() const = 0; diff --git a/projects/stargazer/corps_impl.h b/projects/stargazer/corps_impl.h index ad705c54..f19084f1 100644 --- a/projects/stargazer/corps_impl.h +++ b/projects/stargazer/corps_impl.h @@ -48,6 +48,8 @@ public: bool Exists(const std::string & name) const; const std::string & GetStrError() const { return strError; } + size_t Count() const { return data.size(); } + int OpenSearch() const; int SearchNext(int, CORP_CONF * corp) const; int CloseSearch(int) const; diff --git a/projects/stargazer/main.cpp b/projects/stargazer/main.cpp index cdaee3b0..7cab078d 100644 --- a/projects/stargazer/main.cpp +++ b/projects/stargazer/main.cpp @@ -54,6 +54,8 @@ #include "users_impl.h" #include "admins_impl.h" #include "tariffs_impl.h" +#include "services_impl.h" +#include "corps_impl.h" #include "traffcounter_impl.h" #include "plugin_runner.h" #include "store_loader.h" @@ -446,6 +448,8 @@ TARIFFS_IMPL * tariffs = NULL; ADMINS_IMPL * admins = NULL; USERS_IMPL * users = NULL; TRAFFCOUNTER_IMPL * traffCnt = NULL; +SERVICES_IMPL * services = NULL; +CORPORATIONS_IMPL * corps = NULL; int msgID = -11; { @@ -543,6 +547,8 @@ tariffs = new TARIFFS_IMPL(dataStore); admins = new ADMINS_IMPL(dataStore); users = new USERS_IMPL(settings, dataStore, tariffs, admins->GetSysAdmin()); traffCnt = new TRAFFCOUNTER_IMPL(users, settings->GetRulesFileName()); +services = new SERVICES_IMPL(dataStore); +corps = new CORPORATIONS_IMPL(dataStore); traffCnt->SetMonitorDir(settings->GetMonitorDir()); modSettings = settings->GetModulesSettings(); @@ -560,6 +566,8 @@ for (size_t i = 0; i < modSettings.size(); i++) admins, tariffs, users, + services, + corps, traffCnt, dataStore, settings) @@ -726,6 +734,8 @@ KillExecuters(); StopStgTimer(); WriteServLog("StgTimer: Stop successfull."); +delete corps; +delete services; delete traffCnt; delete users; delete admins; diff --git a/projects/stargazer/plugin_runner.cpp b/projects/stargazer/plugin_runner.cpp index b93d6d0a..0bf159b8 100644 --- a/projects/stargazer/plugin_runner.cpp +++ b/projects/stargazer/plugin_runner.cpp @@ -34,6 +34,8 @@ #include "admins_impl.h" #include "tariffs_impl.h" #include "users_impl.h" +#include "services_impl.h" +#include "corps_impl.h" //----------------------------------------------------------------------------- PLUGIN_RUNNER::PLUGIN_RUNNER(const std::string & pFileName, @@ -41,6 +43,8 @@ PLUGIN_RUNNER::PLUGIN_RUNNER(const std::string & pFileName, ADMINS_IMPL * a, TARIFFS_IMPL * t, USERS_IMPL * u, + SERVICES_IMPL * svc, + CORPORATIONS_IMPL * crp, TRAFFCOUNTER * tc, STORE * st, const SETTINGS_IMPL * s) @@ -54,6 +58,8 @@ PLUGIN_RUNNER::PLUGIN_RUNNER(const std::string & pFileName, admins(a), tariffs(t), users(u), + services(svc), + corps(crp), store(st), traffCnt(tc), stgSettings(s), @@ -72,6 +78,8 @@ PLUGIN_RUNNER::PLUGIN_RUNNER(const PLUGIN_RUNNER & rvalue) admins(rvalue.admins), tariffs(rvalue.tariffs), users(rvalue.users), + services(rvalue.services), + corps(rvalue.corps), store(rvalue.store), traffCnt(rvalue.traffCnt), stgSettings(rvalue.stgSettings), @@ -91,6 +99,8 @@ isRunning = rvalue.isRunning; admins = rvalue.admins; tariffs = rvalue.tariffs; users = rvalue.users; +services = rvalue.services; +corps = rvalue.corps; store = rvalue.store; traffCnt = rvalue.traffCnt; stgSettings = rvalue.stgSettings; @@ -137,6 +147,8 @@ if (!plugin) plugin->SetTariffs(tariffs); plugin->SetAdmins(admins); plugin->SetUsers(users); +plugin->SetServices(services); +plugin->SetCorporations(corps); plugin->SetTraffcounter(traffCnt); plugin->SetStore(store); plugin->SetStgSettings(stgSettings); diff --git a/projects/stargazer/plugin_runner.h b/projects/stargazer/plugin_runner.h index 412c5141..8e2272bf 100644 --- a/projects/stargazer/plugin_runner.h +++ b/projects/stargazer/plugin_runner.h @@ -37,6 +37,8 @@ class SETTINGS_IMPL; class ADMINS_IMPL; class TARIFFS_IMPL; class USERS_IMPL; +class SERVICES_IMPL; +class CORPORATIONS_IMPL; class TRAFFCOUNTER; class STORE; @@ -48,6 +50,8 @@ public: ADMINS_IMPL * admins, TARIFFS_IMPL * tariffs, USERS_IMPL * users, + SERVICES_IMPL * services, + CORPORATIONS_IMPL * corporations, TRAFFCOUNTER * tc, STORE * store, const SETTINGS_IMPL * s); @@ -86,6 +90,8 @@ private: ADMINS_IMPL * admins; TARIFFS_IMPL * tariffs; USERS_IMPL * users; + SERVICES_IMPL * services; + CORPORATIONS_IMPL * corps; STORE * store; TRAFFCOUNTER * traffCnt; const SETTINGS_IMPL * stgSettings; diff --git a/projects/stargazer/services_impl.h b/projects/stargazer/services_impl.h index d0c1c52c..148676d7 100644 --- a/projects/stargazer/services_impl.h +++ b/projects/stargazer/services_impl.h @@ -48,6 +48,8 @@ public: bool Exists(const std::string & name) const; const std::string & GetStrError() const { return strError; } + size_t Count() const { return data.size(); } + int OpenSearch() const; int SearchNext(int, SERVICE_CONF * service) const; int CloseSearch(int) const;