-
Notifications
You must be signed in to change notification settings - Fork 110
/
Configure.h
executable file
·58 lines (47 loc) · 1.36 KB
/
Configure.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#pragma once
#include <map>
#include <string>
#include <fstream>
#include "httpCommon.h"
using namespace std;
class Configure
{
public:
~Configure() {
cfg = NULL;
};
static Configure *readConfigFile(const char *filePath);
string &getValue(const char *key);
string url;
string heartbeat;
string notify;
unsigned short statis_port;
unsigned short heartbeat_port;
unsigned int timeout;
unsigned int sleep_mill;
int req_per_second;
int max_connections;
vector<string> http_header;
private:
Configure(){
info["server_url"] = SERVER_URL;
info["statis_port"] = HTTP_STATISTIC_PORT;
info["heartbeat_port"] = EVENT_LISTEN_PORT;
info["timeout"] = TIME_OUT_SECONDS;
info["sleep_mill"] = THREAD_SLEEP_MILLI;
info["msg_heart_beat"] = MESSAGE_HEARTBEAT_ADDR;
info["msg_notify"] = MESSAGE_NOTIFY_DATA_ADDR;
info[LOG_SWITCH_NAME] = LOG_ON;
info[LOG_FILE] = LOG_DEFAULT_NAME;
info[REQUESTS_PER_SECOND_NAME] = REQUESTS_PER_SECOND;
info[MAX_CONNECTIONS_NAME] = MAX_CONNECTIONS;
};
static void initMember(Configure *cfg);
static void readCommonConfig(Configure *cfg, string &line);
static void readHttpHeader(Configure *cfg, string &line);
static bool changeFlag(string &line);
int ToInt(string &val);
unsigned short ToShort(string &val);
map<string, string> info;
static Configure *cfg;
};