From: Maxim Mamontov Date: Thu, 15 Sep 2011 19:44:58 +0000 (+0300) Subject: Hide or add proper copy ctor and assignement operator, initialize X-Git-Tag: 2.408-rc1~42 X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/7c89c05d7fb37ff6cd90eeab811ef812c03218ec Hide or add proper copy ctor and assignement operator, initialize members via initialization lists in storages code --- diff --git a/projects/stargazer/plugins/store/firebird/firebird_store.cpp b/projects/stargazer/plugins/store/firebird/firebird_store.cpp index f3f435cb..3085981f 100644 --- a/projects/stargazer/plugins/store/firebird/firebird_store.cpp +++ b/projects/stargazer/plugins/store/firebird/firebird_store.cpp @@ -46,18 +46,19 @@ return frsc.GetPlugin(); //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- FIREBIRD_STORE::FIREBIRD_STORE() + : version("firebird_store v.1.4"), + strError(), + db_server("localhost"), + db_database("/var/stg/stargazer.fdb"), + db_user("stg"), + db_password("123456"), + settings(), + db(), + mutex(), + til(IBPP::ilConcurrency), + tlr(IBPP::lrWait) { -db_server = "localhost"; -db_database = "/var/stg/stargazer.fdb"; -db_user = "stg"; -db_password = "123456"; -version = "firebird_store v.1.4"; pthread_mutex_init(&mutex, NULL); - -// Advanced settings defaults - -til = IBPP::ilConcurrency; -tlr = IBPP::lrWait; } //----------------------------------------------------------------------------- FIREBIRD_STORE::~FIREBIRD_STORE() diff --git a/projects/stargazer/plugins/store/firebird/firebird_store.h b/projects/stargazer/plugins/store/firebird/firebird_store.h index 69815fe5..58054cba 100644 --- a/projects/stargazer/plugins/store/firebird/firebird_store.h +++ b/projects/stargazer/plugins/store/firebird/firebird_store.h @@ -114,7 +114,11 @@ public: int RestoreService(SERVICE_CONF * sc, const std::string & name) const; int AddService(const std::string & name) const; int DelService(const std::string & name) const; + private: + FIREBIRD_STORE(const FIREBIRD_STORE & rvalue); + FIREBIRD_STORE & operator=(const FIREBIRD_STORE & rvalue); + std::string version; mutable std::string strError; mutable std::string db_server, db_database, db_user, db_password; diff --git a/projects/stargazer/plugins/store/mysql/mysql_store.cpp b/projects/stargazer/plugins/store/mysql/mysql_store.cpp index 859992e9..e52c055d 100644 --- a/projects/stargazer/plugins/store/mysql/mysql_store.cpp +++ b/projects/stargazer/plugins/store/mysql/mysql_store.cpp @@ -106,13 +106,13 @@ return msc.GetPlugin(); } //----------------------------------------------------------------------------- MYSQL_STORE_SETTINGS::MYSQL_STORE_SETTINGS() - : settings(NULL) + : settings(NULL), + errorStr(), + dbUser(), + dbPass(), + dbName(), + dbHost() { -} -//----------------------------------------------------------------------------- -MYSQL_STORE_SETTINGS::~MYSQL_STORE_SETTINGS() -{ - } //----------------------------------------------------------------------------- int MYSQL_STORE_SETTINGS::ParseParam(const vector & moduleParams, @@ -151,47 +151,16 @@ if (ParseParam(s.moduleParams, "server", dbHost) < 0 && return 0; } //----------------------------------------------------------------------------- -const string & MYSQL_STORE_SETTINGS::GetStrError() const -{ -return errorStr; -} -//----------------------------------------------------------------------------- -string MYSQL_STORE_SETTINGS::GetDBUser() const -{ -return dbUser; -} -//----------------------------------------------------------------------------- -string MYSQL_STORE_SETTINGS::GetDBPassword() const -{ -return dbPass; -} -//----------------------------------------------------------------------------- -string MYSQL_STORE_SETTINGS::GetDBHost() const -{ -return dbHost; -} -//----------------------------------------------------------------------------- -string MYSQL_STORE_SETTINGS::GetDBName() const -{ -return dbName; -} -//----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- MYSQL_STORE::MYSQL_STORE() + : errorStr(), + version("mysql_store v.0.67"), + storeSettings(), + settings() { -version = "mysql_store v.0.67"; }; //----------------------------------------------------------------------------- -MYSQL_STORE::~MYSQL_STORE() -{ -}; -//----------------------------------------------------------------------------- -void MYSQL_STORE::SetSettings(const MODULE_SETTINGS & s) -{ -settings = s; -} -//----------------------------------------------------------------------------- int MYSQL_STORE::MysqlQuery(const char* sQuery,MYSQL * sock) const { int ret,i; @@ -271,16 +240,6 @@ else return ret; } //----------------------------------------------------------------------------- -const string & MYSQL_STORE::GetStrError() const -{ -return errorStr; -} -//----------------------------------------------------------------------------- -const string & MYSQL_STORE::GetVersion() const -{ -return version; -} -//----------------------------------------------------------------------------- bool MYSQL_STORE::IsTablePresent(const string & str,MYSQL * sock) { MYSQL_RES* result; diff --git a/projects/stargazer/plugins/store/mysql/mysql_store.h b/projects/stargazer/plugins/store/mysql/mysql_store.h index 97acf9c9..d0d4f70d 100644 --- a/projects/stargazer/plugins/store/mysql/mysql_store.h +++ b/projects/stargazer/plugins/store/mysql/mysql_store.h @@ -23,16 +23,19 @@ class MYSQL_STORE_SETTINGS { public: MYSQL_STORE_SETTINGS(); - virtual ~MYSQL_STORE_SETTINGS(); + virtual ~MYSQL_STORE_SETTINGS() {} virtual int ParseSettings(const MODULE_SETTINGS & s); - virtual const string & GetStrError() const; + virtual const string & GetStrError() const { return errorStr; } - string GetDBUser() const; - string GetDBPassword() const; - string GetDBHost() const; - string GetDBName() const; + const string & GetDBUser() const { return dbUser; } + const string & GetDBPassword() const { return dbPass; } + const string & GetDBHost() const { return dbHost; } + const string & GetDBName() const { return dbName; } private: + MYSQL_STORE_SETTINGS(const MYSQL_STORE_SETTINGS & rvalue); + MYSQL_STORE_SETTINGS & operator=(const MYSQL_STORE_SETTINGS & rvalue); + const MODULE_SETTINGS * settings; int ParseParam(const vector & moduleParams, @@ -50,8 +53,8 @@ class MYSQL_STORE: public STORE { public: MYSQL_STORE(); - virtual ~MYSQL_STORE(); - virtual const string & GetStrError() const; + virtual ~MYSQL_STORE() {} + virtual const string & GetStrError() const { return errorStr; } //User virtual int GetUsersList(vector * usersList) const; @@ -118,18 +121,19 @@ public: virtual int AddService(const string &) const {return 0;}; virtual int DelService(const string &) const {return 0;}; - //virtual BASE_SETTINGS * GetStoreSettings(); - virtual void SetSettings(const MODULE_SETTINGS & s); + virtual void SetSettings(const MODULE_SETTINGS & s) { settings = s; } virtual int ParseSettings(); - virtual const string & GetVersion() const; + virtual const string & GetVersion() const { return version; } private: + MYSQL_STORE(const MYSQL_STORE & rvalue); + MYSQL_STORE & operator=(const MYSQL_STORE & rvalue); + virtual int WriteLogString(const string & str, const string & login) const; int GetAllParams(vector * ParamList, const string & table, const string & name) const; int CheckAllTables(MYSQL * sock); bool IsTablePresent(const string & str,MYSQL * sock); mutable string errorStr; -// int Reconnect(); int MysqlQuery(const char* sQuery,MYSQL * sock) const; int MysqlGetQuery(const char * Query,MYSQL * & sock) const; int MysqlSetQuery(const char * Query) const; @@ -137,8 +141,6 @@ private: string version; MYSQL_STORE_SETTINGS storeSettings; MODULE_SETTINGS settings; - //mutable MYSQL mysql; - //mutable MYSQL* sock; }; //----------------------------------------------------------------------------- diff --git a/projects/stargazer/plugins/store/postgresql/postgresql_store.cpp b/projects/stargazer/plugins/store/postgresql/postgresql_store.cpp index 19e3efec..073fccab 100644 --- a/projects/stargazer/plugins/store/postgresql/postgresql_store.cpp +++ b/projects/stargazer/plugins/store/postgresql/postgresql_store.cpp @@ -60,10 +60,14 @@ return pqStoreeCreator.GetPlugin(); //----------------------------------------------------------------------------- POSTGRESQL_STORE::POSTGRESQL_STORE() : versionString("postgresql_store v.1.3"), + strError(), server("localhost"), database("stargazer"), user("stg"), password("123456"), + clientEncoding("KOI8"), + settings(), + mutex(), version(0), retries(3), connection(NULL) diff --git a/projects/stargazer/plugins/store/postgresql/postgresql_store.h b/projects/stargazer/plugins/store/postgresql/postgresql_store.h index 8169137e..edba0359 100644 --- a/projects/stargazer/plugins/store/postgresql/postgresql_store.h +++ b/projects/stargazer/plugins/store/postgresql/postgresql_store.h @@ -121,6 +121,9 @@ public: inline const string & GetStrError() const { return strError; }; inline const string & GetVersion() const { return versionString; }; private: + POSTGRESQL_STORE(const POSTGRESQL_STORE & rvalue); + POSTGRESQL_STORE & operator=(const POSTGRESQL_STORE & rvalue); + int StartTransaction() const; int CommitTransaction() const; int RollbackTransaction() const;