You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
186 lines
5.1 KiB
C++
186 lines
5.1 KiB
C++
/****************************************************************************
|
|
** File name : HTConfig.h
|
|
** Description : config parameter
|
|
** Create date : 2018.09.01
|
|
** Auther by : Liuyx
|
|
** Version info : V1.0.01
|
|
** Copyright (C) 2002-2018 xi'an huatek, Inc Co., Ltd
|
|
** Update record:
|
|
** DATE AUTHER DESC
|
|
** -------------------------------------------------------------------------
|
|
** 2018.09.01 Liuyx first build
|
|
****************************************************************************/
|
|
#ifndef __HT_CONFIG_H
|
|
#define __HT_CONFIG_H
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <list>
|
|
// 配置文件路径
|
|
#ifdef _WIN32
|
|
static const char HT_CONFIG_FILE[] = "../etc/ht_service.conf";
|
|
#else
|
|
static const char HT_CONFIG_FILE[] = "../etc/ht_service.conf";
|
|
#endif
|
|
|
|
class TConfig
|
|
{
|
|
public:
|
|
TConfig();
|
|
virtual ~TConfig();
|
|
|
|
static TConfig *getInstance();
|
|
|
|
// 读取配置文件参数
|
|
bool getIniConfig();
|
|
void showConfig();
|
|
|
|
// 设置本地服务器IP
|
|
void setLocalAddr(char *pszAddr);
|
|
|
|
// 获取本地服务器IP
|
|
char *getLocalAddr();
|
|
|
|
// 设置本地服务器端口
|
|
void setLocalPort(unsigned short iPort);
|
|
|
|
// 获取本地服务器端口
|
|
unsigned short getLocalPort();
|
|
|
|
|
|
// 设置远程服务器IP
|
|
void setRemoteAddr(char *pszAddr);
|
|
|
|
// 获取远程服务器IP
|
|
char *getRemoteAddr();
|
|
|
|
// 设置远程服务器端口
|
|
void setRemotePort(unsigned short iPort);
|
|
|
|
// 获取远程服务器端口
|
|
unsigned short getRemotePort();
|
|
|
|
|
|
void setRecvThreadNumber(unsigned int n) ; // 接收线程数
|
|
void setParseThreadNumber(unsigned int n) ; // 解析104线程数
|
|
void setOprationThreadNumber(unsigned int n) ; // 入库线程数
|
|
void setResponeThreadNumber(unsigned int n) ; // 应答线程数
|
|
|
|
unsigned int getRecvThreadNumber() ; // 接收线程数
|
|
unsigned int getParseThreadNumber() ; // 解析104线程数
|
|
unsigned int getOprationThreadNumber() ; // 入库线程数
|
|
unsigned int getResponeThreadNumber() ; // 应答线程数
|
|
|
|
|
|
// 配置数据库配置参数接口
|
|
unsigned int getdbPort() ;
|
|
unsigned int getdbMaxConnect();
|
|
unsigned int getdbMinConnect() ;
|
|
char *getdbHostIP() ;
|
|
char *getdbName() ;
|
|
char *getdbUserName() ;
|
|
char *getdbUserPass() ;
|
|
|
|
void setdbPort(unsigned int port);
|
|
void setdbMaxConnect(unsigned int max);
|
|
void setdbMinConnect(unsigned int min);
|
|
void setdbHostIP(char *pszDBHostIP);
|
|
void setdbName(char *pszDBName);
|
|
void setdbUserName(char *pszDBUserName);
|
|
void setdbUserPass(char *pszDBUserPass);
|
|
|
|
|
|
// socket 相关属性参数配置
|
|
void setFdLimit(unsigned int iCount);
|
|
unsigned int getFdLimit();
|
|
|
|
void setTimeout0(unsigned int t);
|
|
void setTimeout1(unsigned int t);
|
|
void setTimeout2(unsigned int t);
|
|
void setTimeout3(unsigned int t);
|
|
unsigned int getTimeout0();
|
|
unsigned int getTimeout1();
|
|
unsigned int getTimeout2();
|
|
unsigned int getTimeout3();
|
|
|
|
void setK(unsigned int k);
|
|
unsigned int getK();
|
|
|
|
void setW(unsigned int w);
|
|
unsigned int getW();
|
|
|
|
void setLogDebug(char yes);
|
|
void setLogError(char yes);
|
|
void setLogWarning(char yes);
|
|
void setLogPack(char yes);
|
|
void setLogConsole(char yes);
|
|
void setLogMessage(char yes);
|
|
char isLogDebug(void);
|
|
char isLogError(void);
|
|
char isLogWarning(void);
|
|
char isLogPack(void);
|
|
char isLogConsole(void);
|
|
char isLogMessage(void);
|
|
|
|
void setParseBusiData(unsigned char flag);
|
|
unsigned char shouldParseBusiData (void);
|
|
|
|
// version infomation functios
|
|
void setServerVersion(char *pver) ;
|
|
char *getServerVersion();
|
|
|
|
void setMonitor(bool bMonitor);
|
|
bool getMonitor();
|
|
// 读取配置文件函数
|
|
int iniGetString(const char *pszSection, const char *pszEntry, char *pszRetBuf, unsigned int uiBufLen);
|
|
|
|
private:
|
|
static TConfig *p_TConfig;
|
|
|
|
|
|
bool b_monitor_enable ; // 监控标志 true:启用 false: 不启用
|
|
|
|
// server version infomations
|
|
char m_version[32+1]; // format 2013.00.100
|
|
|
|
// database config parameter
|
|
char m_dbHostIP[16];
|
|
char m_dbName[16];
|
|
char m_dbUserName[16];
|
|
char m_dbUserPass[16];
|
|
|
|
unsigned int m_dbMaxConnect;
|
|
unsigned int m_dbMinConnect;
|
|
unsigned int m_dbPort;
|
|
|
|
char m_local_addr[16];
|
|
unsigned m_local_port;
|
|
char m_remote_addr[16] ;
|
|
unsigned int m_remote_port ;
|
|
// socket config
|
|
unsigned int m_fd_limit;
|
|
unsigned int t0,t1,t2,t3,uK,uW;
|
|
|
|
|
|
unsigned int m_recv_num;
|
|
unsigned int m_parse_num;
|
|
unsigned int m_opration_num;
|
|
unsigned int m_respone_num;
|
|
|
|
|
|
// logger
|
|
char m_logdebug; // debug logger
|
|
char m_logwarning; // warning logger
|
|
char m_logerror; // error logger
|
|
char m_logpack; // package print logger
|
|
char m_logconsole; // console print
|
|
char m_logmessage; // message print
|
|
|
|
// Business Data
|
|
unsigned char m_parseBusiData;
|
|
};
|
|
|
|
#endif
|
|
|
|
|