From 5ff8211bdcd5f110621c0ff01fa0854b5e6d9762 Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Thu, 15 Sep 2011 22:28:58 +0300 Subject: [PATCH 1/1] Hide or add proper copy ctor and assignement operator, initialize members via initialization lists in core code --- projects/stargazer/admins_impl.cpp | 4 +++- projects/stargazer/admins_impl.h | 3 +++ projects/stargazer/corps_impl.cpp | 4 +++- projects/stargazer/corps_impl.h | 11 +++++++---- projects/stargazer/services_impl.cpp | 4 +++- projects/stargazer/services_impl.h | 3 +++ projects/stargazer/store_loader.h | 4 ++++ projects/stargazer/tariffs_impl.cpp | 1 + projects/stargazer/tariffs_impl.h | 4 ++++ projects/stargazer/traffcounter_impl.h | 3 +++ projects/stargazer/user_impl.h | 12 ++++++++++++ projects/stargazer/users_impl.h | 23 +++-------------------- 12 files changed, 49 insertions(+), 27 deletions(-) diff --git a/projects/stargazer/admins_impl.cpp b/projects/stargazer/admins_impl.cpp index a780fcb3..cef8682d 100644 --- a/projects/stargazer/admins_impl.cpp +++ b/projects/stargazer/admins_impl.cpp @@ -47,7 +47,9 @@ ADMINS_IMPL::ADMINS_IMPL(STORE * st) store(st), WriteServLog(GetStgLogger()), searchDescriptors(), - handle(0) + handle(0), + mutex(), + strError() { pthread_mutex_init(&mutex, NULL); Read(); diff --git a/projects/stargazer/admins_impl.h b/projects/stargazer/admins_impl.h index a1ca0f98..cb00368c 100644 --- a/projects/stargazer/admins_impl.h +++ b/projects/stargazer/admins_impl.h @@ -70,6 +70,9 @@ public: int CloseSearch(int) const; private: + ADMINS_IMPL(const ADMINS_IMPL & rvalue); + ADMINS_IMPL & operator=(const ADMINS_IMPL & rvalue); + typedef list::iterator admin_iter; typedef list::const_iterator const_admin_iter; diff --git a/projects/stargazer/corps_impl.cpp b/projects/stargazer/corps_impl.cpp index 456523dc..f926d23a 100644 --- a/projects/stargazer/corps_impl.cpp +++ b/projects/stargazer/corps_impl.cpp @@ -33,7 +33,9 @@ CORPORATIONS_IMPL::CORPORATIONS_IMPL(STORE * st) store(st), WriteServLog(GetStgLogger()), searchDescriptors(), - handle(0) + handle(0), + mutex(), + strError() { pthread_mutex_init(&mutex, NULL); Read(); diff --git a/projects/stargazer/corps_impl.h b/projects/stargazer/corps_impl.h index f19084f1..e4552424 100644 --- a/projects/stargazer/corps_impl.h +++ b/projects/stargazer/corps_impl.h @@ -55,18 +55,21 @@ public: int CloseSearch(int) const; private: + CORPORATIONS_IMPL(const CORPORATIONS_IMPL & rvalue); + CORPORATIONS_IMPL & operator=(const CORPORATIONS_IMPL & rvalue); + typedef list::iterator crp_iter; typedef list::const_iterator const_crp_iter; bool Read(); std::list data; - STORE * store; - STG_LOGGER & WriteServLog; + STORE * store; + STG_LOGGER & WriteServLog; mutable std::map searchDescriptors; - mutable unsigned int handle; + mutable unsigned int handle; mutable pthread_mutex_t mutex; - std::string strError; + std::string strError; }; #endif diff --git a/projects/stargazer/services_impl.cpp b/projects/stargazer/services_impl.cpp index f7fd1d49..85b0f4e5 100644 --- a/projects/stargazer/services_impl.cpp +++ b/projects/stargazer/services_impl.cpp @@ -33,7 +33,9 @@ SERVICES_IMPL::SERVICES_IMPL(STORE * st) store(st), WriteServLog(GetStgLogger()), searchDescriptors(), - handle(0) + handle(0), + mutex(), + strError() { pthread_mutex_init(&mutex, NULL); Read(); diff --git a/projects/stargazer/services_impl.h b/projects/stargazer/services_impl.h index 148676d7..2bb9c879 100644 --- a/projects/stargazer/services_impl.h +++ b/projects/stargazer/services_impl.h @@ -55,6 +55,9 @@ public: int CloseSearch(int) const; private: + SERVICES_IMPL(const SERVICES_IMPL & rvalue); + SERVICES_IMPL & operator=(const SERVICES_IMPL & rvalue); + typedef list::iterator srv_iter; typedef list::const_iterator const_srv_iter; diff --git a/projects/stargazer/store_loader.h b/projects/stargazer/store_loader.h index c7911eea..fd8b54a3 100644 --- a/projects/stargazer/store_loader.h +++ b/projects/stargazer/store_loader.h @@ -50,7 +50,11 @@ public: STORE * GetStore() { return plugin; } const std::string & GetStrError() const { return errorStr; } + private: + STORE_LOADER(const STORE_LOADER & rvalue); + STORE_LOADER & operator=(const STORE_LOADER & rvalue); + bool isLoaded; void * handle; STORE * plugin; diff --git a/projects/stargazer/tariffs_impl.cpp b/projects/stargazer/tariffs_impl.cpp index ea3632cb..ab3d970f 100644 --- a/projects/stargazer/tariffs_impl.cpp +++ b/projects/stargazer/tariffs_impl.cpp @@ -46,6 +46,7 @@ TARIFFS_IMPL::TARIFFS_IMPL(STORE * st) tariffs(), store(st), WriteServLog(GetStgLogger()), + mutex(), strError(), noTariff(NO_TARIFF_NAME), onAddNotifiers(), diff --git a/projects/stargazer/tariffs_impl.h b/projects/stargazer/tariffs_impl.h index b50c2f10..caeb811d 100644 --- a/projects/stargazer/tariffs_impl.h +++ b/projects/stargazer/tariffs_impl.h @@ -64,7 +64,11 @@ public: void GetTariffsData(std::list * tdl); const std::string & GetStrError() const { return strError; } + private: + TARIFFS_IMPL(const TARIFFS_IMPL & rvalue); + TARIFFS_IMPL & operator=(const TARIFFS_IMPL & rvalue); + std::list tariffs; STORE * store; STG_LOGGER & WriteServLog; diff --git a/projects/stargazer/traffcounter_impl.h b/projects/stargazer/traffcounter_impl.h index 7afada49..2a9fca5a 100644 --- a/projects/stargazer/traffcounter_impl.h +++ b/projects/stargazer/traffcounter_impl.h @@ -198,6 +198,9 @@ public: size_t RulesCount() const { return rules.size(); } private: + TRAFFCOUNTER_IMPL(const TRAFFCOUNTER_IMPL & rvalue); + TRAFFCOUNTER_IMPL & operator=(const TRAFFCOUNTER_IMPL & rvalue); + bool ParseAddress(const char * ta, RULE * rule) const; uint32_t CalcMask(uint32_t msk) const; void FreeRules(); diff --git a/projects/stargazer/user_impl.h b/projects/stargazer/user_impl.h index 7aab735d..2fc2729e 100644 --- a/projects/stargazer/user_impl.h +++ b/projects/stargazer/user_impl.h @@ -68,6 +68,9 @@ public: void Notify(const int & oldPassive, const int & newPassive); private: + CHG_PASSIVE_NOTIFIER(const CHG_PASSIVE_NOTIFIER & rvalue); + CHG_PASSIVE_NOTIFIER & operator=(const CHG_PASSIVE_NOTIFIER & rvalue); + USER_IMPL * user; }; //----------------------------------------------------------------------------- @@ -78,6 +81,9 @@ public: void Notify(const std::string & oldTariff, const std::string & newTariff); private: + CHG_TARIFF_NOTIFIER(const CHG_TARIFF_NOTIFIER & rvalue); + CHG_TARIFF_NOTIFIER & operator=(const CHG_TARIFF_NOTIFIER & rvalue); + USER_IMPL * user; }; //----------------------------------------------------------------------------- @@ -88,12 +94,18 @@ public: void Notify(const double & oldCash, const double & newCash); private: + CHG_CASH_NOTIFIER(const CHG_CASH_NOTIFIER & rvalue); + CHG_CASH_NOTIFIER & operator=(const CHG_CASH_NOTIFIER & rvalue); + USER_IMPL * user; }; //----------------------------------------------------------------------------- class CHG_IPS_NOTIFIER : public PROPERTY_NOTIFIER_BASE, private NONCOPYABLE { public: + CHG_IPS_NOTIFIER(const CHG_IPS_NOTIFIER & rvalue); + CHG_IPS_NOTIFIER & operator=(const CHG_IPS_NOTIFIER & rvalue); + CHG_IPS_NOTIFIER(USER_IMPL * u) : user(u) {} void Notify(const USER_IPS & oldIPs, const USER_IPS & newIPs); diff --git a/projects/stargazer/users_impl.h b/projects/stargazer/users_impl.h index a7af2989..69f3fbae 100644 --- a/projects/stargazer/users_impl.h +++ b/projects/stargazer/users_impl.h @@ -56,26 +56,6 @@ typedef std::list::const_iterator const_user_iter; class USERS_IMPL; //----------------------------------------------------------------------------- -/*class PROPERTY_NOTIFER_IP_BEFORE: public PROPERTY_NOTIFIER_BASE { -public: - PROPERTY_NOTIFER_IP_BEFORE(USERS_IMPL & us, user_iter u) : users(us), user(u) {} - void Notify(const uint32_t & oldValue, const uint32_t & newValue); - user_iter GetUser() const { return user; } -private: - USERS_IMPL & users; - user_iter user; -}; -//----------------------------------------------------------------------------- -class PROPERTY_NOTIFER_IP_AFTER: public PROPERTY_NOTIFIER_BASE { -public: - PROPERTY_NOTIFER_IP_AFTER(USERS_IMPL & us, user_iter u) : users(us), user(u) {} - void Notify(const uint32_t & oldValue, const uint32_t & newValue); - user_iter GetUser() const { return user; } -private: - USERS_IMPL & users; - user_iter user; -};*/ -//----------------------------------------------------------------------------- struct USER_TO_DEL { USER_TO_DEL() : iter(), @@ -133,6 +113,9 @@ public: int Stop(); private: + USERS_IMPL(const USERS_IMPL & rvalue); + USERS_IMPL & operator=(const USERS_IMPL & rvalue); + void AddToIPIdx(user_iter user); void DelFromIPIdx(uint32_t ip); bool FindByIPIdx(uint32_t ip, user_iter & iter) const; -- 2.44.2