code reorganisation phase-I
[csql.git] / include / Config.h
blob7a1c6a8e84fdca6b1db797f1c356809d1fb7c0bd
1 /***************************************************************************
2 * *
3 * Copyright (C) Lakshya Solutions Ltd. All rights reserved. *
4 * *
5 ***************************************************************************/
7 #ifndef CONFIG_H
8 #define CONFIG_H
9 #include<os.h>
10 #include<Util.h>
12 enum CacheMode {
13 SYNC_MODE=0,
14 ASYNC_MODE=1,
15 UNKNOWN=100
17 enum TDBInfo
19 mysql=0,
20 postgres
23 class ConfigValues
25 public:
26 //All the members of the configuration file
27 char logFile[MAX_FILE_PATH_LEN];
28 char dbFile[MAX_FILE_PATH_LEN];
29 char tableConfigFile[MAX_FILE_PATH_LEN];
30 char dsConfigFile[MAX_FILE_PATH_LEN];// DSN Config file
31 char stderrFile[MAX_FILE_PATH_LEN];
32 char conflResoFile[MAX_FILE_PATH_LEN];
34 bool isDurable;
35 bool mmap;
36 bool isCsqlSqlServer;
37 bool isCache;
38 bool isTwoWay;
40 int siteID;
41 int sysDbKey;
42 int userDbKey;
43 long maxSysSize;
44 long maxDbSize;
45 int pageSize;
46 int maxProcs;
48 long mapAddr;
50 int mutexSecs;
51 int mutexUSecs;
52 int mutexRetries;
53 int lockSecs;
54 int lockUSecs;
55 int lockRetries;
56 int logLevel;
58 int durableMode;
59 char dsn[IDENTIFIER_LENGTH];
60 CacheMode mode;
61 int cacheWaitSecs;
63 int port;
64 int nwResponseTimeout;
65 int nwConnectTimeout;
67 int msgKey;
68 int asyncMsgMax;
69 int shmKeyForId;
70 long maxQueueLogs;
71 int noOfProcessors;
72 int stmtCacheSize;
73 bool isCacheNoParam;
74 bool isMonitor;
77 ConfigValues()
79 strcpy(logFile, "/tmp/log/log.out");
80 strcpy(dbFile, "/tmp/csql/db");
81 strcpy(tableConfigFile, "/tmp/csql/csqltable.conf");
82 strcpy(dsConfigFile,"/tmp/csql/csqlds.conf"); // DSN Config file
83 strcpy(stderrFile, "stderr");
84 strcpy(conflResoFile, "/tmp/csql/ConflResoFile.txt");
86 isDurable = false;
87 mmap = false;
88 isCsqlSqlServer = false;
89 isCache = false;
90 isTwoWay=false;
92 siteID=1;
93 sysDbKey = 2222;
94 userDbKey = 5555;
95 maxSysSize = 10485760;
96 maxDbSize = 104857600;
97 pageSize = 8192;
98 maxProcs = 20;
100 mapAddr=400000000;
102 mutexSecs=0;
103 mutexUSecs=10;
104 mutexRetries = 10;
105 lockSecs =0;
106 lockUSecs = 10;
107 lockRetries = 10;
108 logLevel = 0;
110 durableMode=1;
111 strcpy(dsn,"myodbc3");
112 mode = SYNC_MODE;
113 cacheWaitSecs =10;
115 port = 5678;
116 nwResponseTimeout=3;
117 nwConnectTimeout=5;
118 msgKey=-1;
119 asyncMsgMax = 8192; //default for linux
120 shmKeyForId = -1;
121 maxQueueLogs = 100;
122 noOfProcessors = 1;
123 stmtCacheSize = 10;
124 isCacheNoParam = false;
125 isMonitor = false;
129 class Config
131 ConfigValues cVal;
132 bool isLoaded;
133 int readLine(FILE *fp, char * buffer);
134 int storeKeyVal(char *key, char *val);
135 int validateValues();
137 public:
138 Config() { isLoaded = false; }
139 int readAllValues(char *filename);
140 void print();
141 void logConfig();
142 inline int getPageSize() { return cVal.pageSize; }
143 inline int getMaxProcs() { return cVal.maxProcs; }
144 inline long getMaxSysDbSize() { return cVal.maxSysSize; }
145 inline long getMaxDbSize() { return cVal.maxDbSize; }
146 inline int getSysDbKey() { return cVal.sysDbKey; }
147 inline int getUserDbKey() { return cVal.userDbKey; }
148 inline bool useMmap() { return cVal.mmap; }
149 inline char* getLogFile() { return cVal.logFile; }
150 inline char* getDbFile() { return cVal.dbFile; }
151 inline long getMapAddress() { return cVal.mapAddr; }
152 inline int getMutexSecs() { return cVal.mutexSecs; }
153 inline int getMutexUSecs() { return cVal.mutexUSecs; }
154 inline int getMutexRetries() { return cVal.mutexRetries; }
155 inline int getLockSecs() { return cVal.lockSecs; }
156 inline int getLockUSecs() { return cVal.lockUSecs; }
157 inline int getLockRetries() { return cVal.lockRetries; }
158 inline int getSiteID(){ return cVal.siteID;}
159 inline bool useCache() { return cVal.isCache; }
160 inline int getCacheMode() { return (int) cVal.mode; }
161 inline char* getDSN() { return cVal.dsn; }
162 inline char* getDsConfigFile() { return cVal.dsConfigFile; }
163 inline char* getTableConfigFile() { return cVal.tableConfigFile; }
164 inline char* getStderrFile() { return cVal.stderrFile; }
165 inline bool useDurability() { return cVal.isDurable; }
166 inline int getDurableMode() { return cVal.durableMode; }
167 inline bool useCsqlSqlServer() { return cVal.isCsqlSqlServer; }
168 inline int getPort() { return cVal.port; }
169 inline char* getConflResoFile() { return cVal.conflResoFile; }
170 inline long getMaxQueueLogs() { return cVal.maxQueueLogs; }
171 inline int getMsgKey() { return cVal.msgKey; }
172 inline int getAsyncMsgMax() { return cVal.asyncMsgMax; }
173 inline int getShmIDKey() { return cVal.shmKeyForId; }
174 inline int getNetworkResponseTimeout() { return cVal.nwResponseTimeout; }
175 inline int getNetworkConnectTimeout() { return cVal.nwConnectTimeout; }
176 inline bool useTwoWayCache() { return cVal.isTwoWay; }
177 inline int getCacheWaitSecs() { return cVal.cacheWaitSecs; }
178 inline int getLogLevel() { return cVal.logLevel; }
179 inline int getNoOfProcessors() { return cVal.noOfProcessors; }
180 inline int getStmtCacheSize() { return cVal.stmtCacheSize; }
181 inline bool useCacheNoParam() { return cVal.isCacheNoParam; }
182 inline bool useMonitorServers() { return cVal.isMonitor; }
185 class Conf
187 public:
188 static Config config;
189 static Logger logger;
192 #endif