Files
interactive/gts/cc_statd/src/Configs.h
T
2026-08-07 17:38:18 +09:00

110 lines
2.6 KiB
C++

/***************************************************************************
Config Class Header ( Config.h )
-----------------------------------------
begin : 2013/05/28
copyright : (C) 2013 Solbox Inc.
author : Development 1 Team
- 2013/05/28 - 1st dadamin
email : dev1@solbox.com
version : 3.2.0
CopyRight(C) 2005 Solbox Inc. All Rights reserved.
Redistribution and use in source and binary forms, with or with out
modification, are not permitted in outside of Solbox Inc.
***************************************************************************/
#ifndef __CC_STATD_CONFIG_H__
#define __CC_STATD_CONFIG_H__
void StringSplit(string str, string delim, vector<string> &results, bool bUseEmpty /*= false*/);
class CDataBaseInfo
{
public:
CDataBaseInfo() {}
~CDataBaseInfo() {}
public:
int m_poolcnt;
string m_connstr;
};
class CCommonConfig
{
public:
CCommonConfig( string szFilename, string szProgramName );
virtual ~CCommonConfig();
bool LoadConf();
bool CheckValue();
void PrintValue();
inline const char * GetErrMessage() { return m_szErrMessage.c_str(); }
inline const char * GetAppLogRoot() { return m_szAppLogRoot.c_str(); }
inline int GetAppLogLevel() { return m_nLogLevel; }
protected:
string m_szConfigFile;
string m_szProgramName;
string m_szErrMessage;
// log
string m_szAppLogRoot;
int m_nLogLevel;
private:
};
class CMyConfig : public CCommonConfig
{
public:
static bool Init( string szProgramName, string szFilename );
static void Exit();
static CMyConfig* GetInstance();
private:
static CMyConfig* m_pInstance;
public:
bool LoadConf();
bool CheckValue();
inline int GetTCPListenPort() { return m_TcpListenPort; }
inline int GetWorkProcessCnt() { return m_WorkProcessCnt; }
inline int GetWorkThreadCnt() { return m_WorkThreadCnt; }
inline int GetUsedDBTypeCnt() { return m_usedDBTypeVec.size(); }
inline const char * GetUsedDBType(int index) { return m_usedDBTypeVec[index].c_str(); }
bool FindUsedDBType(string & k);
inline int GetDBInfoCnt() { return m_DBInfoMap.size(); }
inline void GetDBInfo( string key, map<string, CDataBaseInfo> & info) { info = m_DBInfoMap.find(key)->second; }
void SetFailLogPath(string & path);
inline const char * GetFailLogPath() { return m_FailLogPath.c_str(); }
void PrintValue();
protected:
CMyConfig( string szFilename, string szProgramName );
virtual ~CMyConfig();
protected:
int m_TcpListenPort;
int m_WorkProcessCnt;
int m_WorkThreadCnt;
vector<string> m_usedDBTypeVec;
map<string, map<string, CDataBaseInfo> > m_DBInfoMap;
string m_FailLogPath;
private:
};
#endif // __CC_STATD_CONFIG_H__