statement caching for select statement with no parameter and with predicates. Bu
[csql.git] / include / Config.h
blobd3ab3d86592d3f7d522eded4a15c5d97b420fbd3
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;
76 ConfigValues()
78 strcpy(logFile, "/tmp/log/log.out");
79 strcpy(dbFile, "/tmp/csql/db");
80 strcpy(tableConfigFile, "/tmp/csql/csqltable.conf");
81 strcpy(dsConfigFile,"/tmp/csql/csqlds.conf"); // DSN Config file
82 strcpy(stderrFile, "stderr");
83 strcpy(conflResoFile, "/tmp/csql/ConflResoFile.txt");
85 isDurable = false;
86 mmap = false;
87 isCsqlSqlServer = false;
88 isCache = false;
89 isTwoWay=false;
91 siteID=1;
92 sysDbKey = 2222;
93 userDbKey = 5555;
94 maxSysSize = 10485760;
95 maxDbSize = 104857600;
96 pageSize = 8192;
97 maxProcs = 20;
99 mapAddr=400000000;
101 mutexSecs=0;
102 mutexUSecs=10;
103 mutexRetries = 10;
104 lockSecs =0;
105 lockUSecs = 10;
106 lockRetries = 10;
107 logLevel = 0;
109 durableMode=1;
110 strcpy(dsn,"myodbc3");
111 mode = SYNC_MODE;
112 cacheWaitSecs =10;
114 port = 5678;
115 nwResponseTimeout=3;
116 nwConnectTimeout=5;
117 msgKey=-1;
118 asyncMsgMax = 8192; //default for linux
119 shmKeyForId = -1;
120 maxQueueLogs = 100;
121 noOfProcessors = 1;
122 stmtCacheSize = 10;
123 isCacheNoParam = false;
128 class Config
130 ConfigValues cVal;
131 bool isLoaded;
132 int readLine(FILE *fp, char * buffer);
133 int storeKeyVal(char *key, char *val);
134 int validateValues();
136 public:
137 Config() { isLoaded = false; }
138 int readAllValues(char *filename);
139 void print();
140 void logConfig();
141 inline int getPageSize() { return cVal.pageSize; }
142 inline int getMaxProcs() { return cVal.maxProcs; }
143 inline long getMaxSysDbSize() { return cVal.maxSysSize; }
144 inline long getMaxDbSize() { return cVal.maxDbSize; }
145 inline int getSysDbKey() { return cVal.sysDbKey; }
146 inline int getUserDbKey() { return cVal.userDbKey; }
147 inline bool useMmap() { return cVal.mmap; }
148 inline char* getLogFile() { return cVal.logFile; }
149 inline char* getDbFile() { return cVal.dbFile; }
150 inline long getMapAddress() { return cVal.mapAddr; }
151 inline int getMutexSecs() { return cVal.mutexSecs; }
152 inline int getMutexUSecs() { return cVal.mutexUSecs; }
153 inline int getMutexRetries() { return cVal.mutexRetries; }
154 inline int getLockSecs() { return cVal.lockSecs; }
155 inline int getLockUSecs() { return cVal.lockUSecs; }
156 inline int getLockRetries() { return cVal.lockRetries; }
157 inline int getSiteID(){ return cVal.siteID;}
158 inline bool useCache() { return cVal.isCache; }
159 inline int getCacheMode() { return (int) cVal.mode; }
160 inline char* getDSN() { return cVal.dsn; }
161 inline char* getDsConfigFile() { return cVal.dsConfigFile; }
162 inline char* getTableConfigFile() { return cVal.tableConfigFile; }
163 inline char* getStderrFile() { return cVal.stderrFile; }
164 inline bool useDurability() { return cVal.isDurable; }
165 inline int getDurableMode() { return cVal.durableMode; }
166 inline bool useCsqlSqlServer() { return cVal.isCsqlSqlServer; }
167 inline int getPort() { return cVal.port; }
168 inline char* getConflResoFile() { return cVal.conflResoFile; }
169 inline long getMaxQueueLogs() { return cVal.maxQueueLogs; }
170 inline int getMsgKey() { return cVal.msgKey; }
171 inline int getAsyncMsgMax() { return cVal.asyncMsgMax; }
172 inline int getShmIDKey() { return cVal.shmKeyForId; }
173 inline int getNetworkResponseTimeout() { return cVal.nwResponseTimeout; }
174 inline int getNetworkConnectTimeout() { return cVal.nwConnectTimeout; }
175 inline bool useTwoWayCache() { return cVal.isTwoWay; }
176 inline int getCacheWaitSecs() { return cVal.cacheWaitSecs; }
177 inline int getLogLevel() { return cVal.logLevel; }
178 inline int getNoOfProcessors() { return cVal.noOfProcessors; }
179 inline int getStmtCacheSize() { return cVal.stmtCacheSize; }
180 inline bool useCacheNoParam() { return cVal.isCacheNoParam; }
184 class Conf
186 public:
187 static Config config;
188 static Logger logger;
191 #endif