From: Maxim Mamontov Date: Wed, 14 Sep 2011 15:14:03 +0000 (+0300) Subject: Initialize some members in initialization lists X-Git-Tag: 2.408-rc1~51 X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/ed144772874a7495b39abdf3bd9dbb0fe1c22fe8 Initialize some members in initialization lists --- diff --git a/projects/stargazer/main.cpp b/projects/stargazer/main.cpp index 7cab078d..5b4a06fc 100644 --- a/projects/stargazer/main.cpp +++ b/projects/stargazer/main.cpp @@ -93,8 +93,8 @@ return lhs.GetStopPosition() > rhs.GetStopPosition(); class STG_STOPPER { public: - STG_STOPPER() { nonstop = true; } - bool GetStatus() const { return nonstop; }; + STG_STOPPER() : nonstop(true) {} + bool GetStatus() const { return nonstop; } #ifdef NO_DAEMON void Stop(const char * __file__, int __line__) #else diff --git a/projects/stargazer/traffcounter_impl.cpp b/projects/stargazer/traffcounter_impl.cpp index ff18a5e2..ae7f1dfb 100644 --- a/projects/stargazer/traffcounter_impl.cpp +++ b/projects/stargazer/traffcounter_impl.cpp @@ -59,12 +59,21 @@ tcp = 0, udp, icmp, tcp_udp, all //----------------------------------------------------------------------------- TRAFFCOUNTER_IMPL::TRAFFCOUNTER_IMPL(USERS_IMPL * u, const std::string & fn) : TRAFFCOUNTER(), + rules(), + packets(), + ip2packets(), + dirName(), WriteServLog(GetStgLogger()), rulesFileName(fn), + monitorDir(), monitoring(false), users(u), running(false), stopped(true), + mutex(), + thread(), + ipBeforeNotifiers(), + ipAfterNotifiers(), addUserNotifier(*this), delUserNotifier(*this) { diff --git a/projects/stargazer/traffcounter_impl.h b/projects/stargazer/traffcounter_impl.h index 225a636e..7afada49 100644 --- a/projects/stargazer/traffcounter_impl.h +++ b/projects/stargazer/traffcounter_impl.h @@ -102,33 +102,47 @@ class TRAFFCOUNTER_IMPL; //----------------------------------------------------------------------------- class TRF_IP_BEFORE: public PROPERTY_NOTIFIER_BASE { public: - TRF_IP_BEFORE(TRAFFCOUNTER_IMPL & t, USER_IMPL * u) - : PROPERTY_NOTIFIER_BASE(), - traffCnt(t), - user(u) - {} - void Notify(const uint32_t & oldValue, const uint32_t & newValue); - void SetUser(USER_IMPL * u) { user = u; } - USER_IMPL * GetUser() const { return user; } + TRF_IP_BEFORE(TRAFFCOUNTER_IMPL & t, USER_IMPL * u) + : PROPERTY_NOTIFIER_BASE(), + traffCnt(t), + user(u) + {} + TRF_IP_BEFORE(const TRF_IP_BEFORE & rvalue) + : PROPERTY_NOTIFIER_BASE(), + traffCnt(rvalue.traffCnt), + user(rvalue.user) + {} + void Notify(const uint32_t & oldValue, const uint32_t & newValue); + void SetUser(USER_IMPL * u) { user = u; } + USER_IMPL * GetUser() const { return user; } private: + TRF_IP_BEFORE & operator=(const TRF_IP_BEFORE & rvalue); + TRAFFCOUNTER_IMPL & traffCnt; - USER_IMPL * user; + USER_IMPL * user; }; //----------------------------------------------------------------------------- class TRF_IP_AFTER: public PROPERTY_NOTIFIER_BASE { public: - TRF_IP_AFTER(TRAFFCOUNTER_IMPL & t, USER_IMPL * u) - : PROPERTY_NOTIFIER_BASE(), - traffCnt(t), - user(u) - {} - void Notify(const uint32_t & oldValue, const uint32_t & newValue); - void SetUser(USER_IMPL * u) { user = u; } - USER_IMPL * GetUser() const { return user; } + TRF_IP_AFTER(TRAFFCOUNTER_IMPL & t, USER_IMPL * u) + : PROPERTY_NOTIFIER_BASE(), + traffCnt(t), + user(u) + {} + TRF_IP_AFTER(const TRF_IP_AFTER & rvalue) + : PROPERTY_NOTIFIER_BASE(), + traffCnt(rvalue.traffCnt), + user(rvalue.user) + {} + void Notify(const uint32_t & oldValue, const uint32_t & newValue); + void SetUser(USER_IMPL * u) { user = u; } + USER_IMPL * GetUser() const { return user; } private: + TRF_IP_AFTER & operator=(const TRF_IP_AFTER & rvalue); + TRAFFCOUNTER_IMPL & traffCnt; - USER_IMPL * user; + USER_IMPL * user; }; //----------------------------------------------------------------------------- class ADD_USER_NONIFIER: public NOTIFIER_BASE { @@ -139,7 +153,11 @@ public: {} virtual ~ADD_USER_NONIFIER() {} void Notify(const USER_IMPL_PTR & user); + private: + ADD_USER_NONIFIER(const ADD_USER_NONIFIER & rvalue); + ADD_USER_NONIFIER & operator=(const ADD_USER_NONIFIER & rvalue); + TRAFFCOUNTER_IMPL & traffCnt; }; //----------------------------------------------------------------------------- @@ -151,7 +169,11 @@ public: {} virtual ~DEL_USER_NONIFIER() {} void Notify(const USER_IMPL_PTR & user); + private: + DEL_USER_NONIFIER(const DEL_USER_NONIFIER & rvalue); + DEL_USER_NONIFIER & operator=(const DEL_USER_NONIFIER & rvalue); + TRAFFCOUNTER_IMPL & traffCnt; }; //-----------------------------------------------------------------------------