two way caching changes related to config, deamon
[csql.git] / include / Config.h
blobf9cf64e9fd5d662a9b980daea90501bada9df96f
1 /***************************************************************************
2 * Copyright (C) 2007 by www.databasecache.com *
3 * Contact: praba_tuty@databasecache.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 ***************************************************************************/
16 #ifndef CONFIG_H
17 #define CONFIG_H
18 #include<os.h>
19 class ConfigValues
21 public:
22 //All the members of the configuration file
23 int pageSize;
24 int maxProcs;
25 long maxSysSize;
26 long maxDbSize;
27 int sysDbKey;
28 int userDbKey;
29 char logFile[MAX_FILE_PATH_LEN];
30 long mapAddr;
31 int mutexSecs;
32 int mutexUSecs;
33 int mutexRetries;
34 int lockSecs;
35 int lockUSecs;
36 int lockRetries;
38 bool isCache;
39 char dsn[IDENTIFIER_LENGTH];
40 char tableConfigFile[MAX_FILE_PATH_LEN];
41 bool isTwoWay;
42 int cacheWaitSecs;
44 bool isReplication;
45 char replConfigFile[MAX_FILE_PATH_LEN];
46 int networkID;
47 int cacheNetworkID;
49 long logStoreSize;
50 int nwResponseTimeout;
51 int nwConnectTimeout;
53 ConfigValues()
55 pageSize = 8192;
56 maxProcs = 20;
57 maxSysSize = 10485760;
58 maxDbSize = 104857600;
59 sysDbKey = 2222;
60 userDbKey = 5555;
61 strcpy(logFile, "/tmp/log/log.out");
62 mapAddr=400000000;
63 mutexSecs=0;
64 mutexUSecs=10;
65 mutexRetries = 10;
66 lockSecs =0;
67 lockUSecs = 10;
68 lockRetries = 10;
69 isCache = false;
70 cacheNetworkID =-1;
71 strcpy(dsn, "myodbc3");
72 strcpy(tableConfigFile, "/tmp/csql/csqltable.conf");
73 isReplication = false;
74 strcpy(replConfigFile, "/tmp/csql/csqlnw.conf");
75 logStoreSize = 10485760;
76 networkID=-1;
77 nwResponseTimeout=3;
78 nwConnectTimeout=5;
79 isTwoWay=true;
80 cacheWaitSecs =10;
84 class Config
86 ConfigValues cVal;
87 int readLine(FILE *fp, char * buffer);
88 int storeKeyVal(char *key, char *val);
89 int validateValues();
91 public:
92 int readAllValues(char *filename);
93 void print();
95 inline int getPageSize() { return cVal.pageSize; }
96 inline int getMaxProcs() { return cVal.maxProcs; }
97 inline long getMaxSysDbSize() { return cVal.maxSysSize; }
98 inline long getMaxDbSize() { return cVal.maxDbSize; }
99 inline int getSysDbKey() { return cVal.sysDbKey; }
100 inline int getUserDbKey() { return cVal.userDbKey; }
101 inline char* getLogFile() { return cVal.logFile; }
102 inline long getMapAddress() { return cVal.mapAddr; }
103 inline int getMutexSecs() { return cVal.mutexSecs; }
104 inline int getMutexUSecs() { return cVal.mutexUSecs; }
105 inline int getMutexRetries() { return cVal.mutexRetries; }
106 inline int getLockSecs() { return cVal.lockSecs; }
107 inline int getLockUSecs() { return cVal.lockUSecs; }
108 inline int getLockRetries() { return cVal.lockRetries; }
109 inline bool useCache() { return cVal.isCache; }
110 inline char* getDSN() { return cVal.dsn; }
111 inline char* getTableConfigFile() { return cVal.tableConfigFile; }
112 inline bool useReplication() { return cVal.isReplication; }
113 inline char* getReplConfigFile() { return cVal.replConfigFile; }
114 inline long getMaxLogStoreSize() { return cVal.logStoreSize; }
115 inline int getNetworkID() { return cVal.networkID; }
116 inline int getCacheNetworkID() { return cVal.cacheNetworkID; }
117 inline int getNetworkResponseTimeout() { return cVal.nwResponseTimeout; }
118 inline int getNetworkConnectTimeout() { return cVal.nwConnectTimeout; }
119 inline bool useTwoWayCache() { return cVal.isTwoWay; }
120 inline int getCacheWaitSecs() { return cVal.cacheWaitSecs; }
123 class Conf
125 public:
126 static Config config;
130 #endif