]> git.stg.codes - stg.git/commitdiff
Set services and corps to plugins
authorMaxim Mamontov <faust.madf@gmail.com>
Sat, 13 Aug 2011 16:42:30 +0000 (19:42 +0300)
committerMaxim Mamontov <faust.madf@gmail.com>
Sat, 13 Aug 2011 16:42:30 +0000 (19:42 +0300)
include/stg/corporations.h
include/stg/services.h
projects/stargazer/corps_impl.h
projects/stargazer/main.cpp
projects/stargazer/plugin_runner.cpp
projects/stargazer/plugin_runner.h
projects/stargazer/services_impl.h

index ad23967ed96119ab1f63016782ad182cab02fad9..88c1e8bdc810c9741afccec4c696ddd5a5914a06 100644 (file)
 
 #include "corp_conf.h"
 
 
 #include "corp_conf.h"
 
+class ADMIN;
+
 class CORPORATIONS {
 public:
 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;
 
     virtual const std::string & GetStrError() const = 0;
     virtual size_t Count() const = 0;
 
index 131e2b5520b8fb1d259ec3a4611379e2879badab..5ff7a1a8a7eab0775af70858e4948dcca1165314 100644 (file)
 
 #include "service_conf.h"
 
 
 #include "service_conf.h"
 
+class ADMIN;
+
 class SERVICES {
 public:
 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;
 
     virtual const std::string & GetStrError() const = 0;
     virtual size_t Count() const = 0;
 
index ad705c54a830f00ecb8c87f3e03e0b7972cd28d2..f19084f106967e2019b41ae5240b74565244a123 100644 (file)
@@ -48,6 +48,8 @@ public:
     bool Exists(const std::string & name) const;
     const std::string & GetStrError() const { return strError; }
 
     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;
     int OpenSearch() const;
     int SearchNext(int, CORP_CONF * corp) const;
     int CloseSearch(int) const;
index cdaee3b0cb61b3ea54e90c0878cfdfbf4635518c..7cab078d87bbe567c680b2021a6442e8312b44f7 100644 (file)
@@ -54,6 +54,8 @@
 #include "users_impl.h"
 #include "admins_impl.h"
 #include "tariffs_impl.h"
 #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"
 #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;
 ADMINS_IMPL * admins = NULL;
 USERS_IMPL * users = NULL;
 TRAFFCOUNTER_IMPL * traffCnt = NULL;
+SERVICES_IMPL * services = NULL;
+CORPORATIONS_IMPL * corps = NULL;
 int msgID = -11;
 
     {
 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());
 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();
 traffCnt->SetMonitorDir(settings->GetMonitorDir());
 
 modSettings = settings->GetModulesSettings();
@@ -560,6 +566,8 @@ for (size_t i = 0; i < modSettings.size(); i++)
                       admins,
                       tariffs,
                       users,
                       admins,
                       tariffs,
                       users,
+                      services,
+                      corps,
                       traffCnt,
                       dataStore,
                       settings)
                       traffCnt,
                       dataStore,
                       settings)
@@ -726,6 +734,8 @@ KillExecuters();
 StopStgTimer();
 WriteServLog("StgTimer: Stop successfull.");
 
 StopStgTimer();
 WriteServLog("StgTimer: Stop successfull.");
 
+delete corps;
+delete services;
 delete traffCnt;
 delete users;
 delete admins;
 delete traffCnt;
 delete users;
 delete admins;
index b93d6d0a45d3cd1d67d75c60ccade79e4d26a92e..0bf159b8ee5bf58601bbf88a35269e9772060629 100644 (file)
@@ -34,6 +34,8 @@
 #include "admins_impl.h"
 #include "tariffs_impl.h"
 #include "users_impl.h"
 #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,
 
 //-----------------------------------------------------------------------------
 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,
                              ADMINS_IMPL * a,
                              TARIFFS_IMPL * t,
                              USERS_IMPL * u,
+                             SERVICES_IMPL * svc,
+                             CORPORATIONS_IMPL * crp,
                              TRAFFCOUNTER * tc,
                              STORE * st,
                              const SETTINGS_IMPL * s)
                              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),
       admins(a),
       tariffs(t),
       users(u),
+      services(svc),
+      corps(crp),
       store(st),
       traffCnt(tc),
       stgSettings(s),
       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),
       admins(rvalue.admins),
       tariffs(rvalue.tariffs),
       users(rvalue.users),
+      services(rvalue.services),
+      corps(rvalue.corps),
       store(rvalue.store),
       traffCnt(rvalue.traffCnt),
       stgSettings(rvalue.stgSettings),
       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;
 admins = rvalue.admins;
 tariffs = rvalue.tariffs;
 users = rvalue.users;
+services = rvalue.services;
+corps = rvalue.corps;
 store = rvalue.store;
 traffCnt = rvalue.traffCnt;
 stgSettings = rvalue.stgSettings;
 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->SetTariffs(tariffs);
 plugin->SetAdmins(admins);
 plugin->SetUsers(users);
+plugin->SetServices(services);
+plugin->SetCorporations(corps);
 plugin->SetTraffcounter(traffCnt);
 plugin->SetStore(store);
 plugin->SetStgSettings(stgSettings);
 plugin->SetTraffcounter(traffCnt);
 plugin->SetStore(store);
 plugin->SetStgSettings(stgSettings);
index 412c51413361d7a7e93cb39b4c9e08749704dffc..8e2272bfb1cf9ba84a9d08d3a4a8c1425c010310 100644 (file)
@@ -37,6 +37,8 @@ class SETTINGS_IMPL;
 class ADMINS_IMPL;
 class TARIFFS_IMPL;
 class USERS_IMPL;
 class ADMINS_IMPL;
 class TARIFFS_IMPL;
 class USERS_IMPL;
+class SERVICES_IMPL;
+class CORPORATIONS_IMPL;
 class TRAFFCOUNTER;
 class STORE;
 
 class TRAFFCOUNTER;
 class STORE;
 
@@ -48,6 +50,8 @@ public:
                   ADMINS_IMPL * admins,
                   TARIFFS_IMPL * tariffs,
                   USERS_IMPL * users,
                   ADMINS_IMPL * admins,
                   TARIFFS_IMPL * tariffs,
                   USERS_IMPL * users,
+                  SERVICES_IMPL * services,
+                  CORPORATIONS_IMPL * corporations,
                   TRAFFCOUNTER * tc,
                   STORE * store,
                   const SETTINGS_IMPL * s);
                   TRAFFCOUNTER * tc,
                   STORE * store,
                   const SETTINGS_IMPL * s);
@@ -86,6 +90,8 @@ private:
     ADMINS_IMPL *   admins;
     TARIFFS_IMPL *  tariffs;
     USERS_IMPL *    users;
     ADMINS_IMPL *   admins;
     TARIFFS_IMPL *  tariffs;
     USERS_IMPL *    users;
+    SERVICES_IMPL * services;
+    CORPORATIONS_IMPL * corps;
     STORE *         store;
     TRAFFCOUNTER *  traffCnt;
     const SETTINGS_IMPL * stgSettings;
     STORE *         store;
     TRAFFCOUNTER *  traffCnt;
     const SETTINGS_IMPL * stgSettings;
index d0c1c52ca690c09245782f76d2df3021e3fed38f..148676d74e1fdf17f7ed726bfbf64188d636f6fa 100644 (file)
@@ -48,6 +48,8 @@ public:
     bool Exists(const std::string & name) const;
     const std::string & GetStrError() const { return strError; }
 
     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;
     int OpenSearch() const;
     int SearchNext(int, SERVICE_CONF * service) const;
     int CloseSearch(int) const;