#ifndef _GLOBALCONFIG_H
#define _GLOBALCONFIG_H
#include <string>
using namespace std;
class CGlobalConfig
{
public:
CGlobalConfig();
~CGlobalConfig();
static CGlobalConfig* GetInstance()
{
static CGlobalConfig inst;
return &inst;
}
void Init();
int GetClientType()
{
return m_iClientType;
}
……….
private:
int m_iClientType;//客户端显示类型
string m_strCMSIP; // CMS的IP
int m_iCMSPort; // CMS的端口
string m_strMQIP; // MQ的IP
//………
/** @fn DecryptAES
* @brief 解密
* @para const string& strKey 秘钥
* @para const string& strData 数据
* @return string 解密后的数据
*/
string DecryptAES( const string& strKey, const string& strData );
};
#endif // _GLOBALCONFIG_H
使用方法:
string strPlatformIP = CGlobalConfig::GetInstance()->GetCMSIP()/*"10.33.29.131"*/;
int iPlatformPort = CGlobalConfig::GetInstance()->GetCMSPort();
string strAMQIP = CGlobalConfig::GetInstance()->GetMQIP();