using tree index
[csql.git] / include / Config.h
blobb5a42ca8448dc2682e28b3fe1f33f57a3ec43727
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 char dbFile[MAX_FILE_PATH_LEN];
31 long mapAddr;
32 int mutexSecs;
33 int mutexUSecs;
34 int mutexRetries;
35 int lockSecs;
36 int lockUSecs;
37 int lockRetries;
39 int cacheId;
40 bool isCache;
41 char dsn[IDENTIFIER_LENGTH];
42 char tableConfigFile[MAX_FILE_PATH_LEN];
43 bool isTwoWay;
44 int cacheWaitSecs;
46 bool isReplication;
47 char replConfigFile[MAX_FILE_PATH_LEN];
48 int networkID;
49 int cacheNetworkID;
51 long logStoreSize;
52 int nwResponseTimeout;
53 int nwConnectTimeout;
55 ConfigValues()
57 pageSize = 8192;
58 maxProcs = 20;
59 maxSysSize = 10485760;
60 maxDbSize = 104857600;
61 sysDbKey = 2222;
62 userDbKey = 5555;
63 strcpy(logFile, "/tmp/log/log.out");
64 strcpy(dbFile, "/tmp/csql/csql.db");
65 mapAddr=400000000;
66 mutexSecs=0;
67 mutexUSecs=10;
68 mutexRetries = 10;
69 lockSecs =0;
70 lockUSecs = 10;
71 lockRetries = 10;
72 cacheId=1;
73 isCache = false;
74 cacheNetworkID =-1;
75 strcpy(dsn, "myodbc3");
76 strcpy(tableConfigFile, "/tmp/csql/csqltable.conf");
77 isReplication = false;
78 strcpy(replConfigFile, "/tmp/csql/csqlnw.conf");
79 logStoreSize = 10485760;
80 networkID=-1;
81 nwResponseTimeout=3;
82 nwConnectTimeout=5;
83 isTwoWay=true;
84 cacheWaitSecs =10;
88 class Config
90 ConfigValues cVal;
91 int readLine(FILE *fp, char * buffer);
92 int storeKeyVal(char *key, char *val);
93 int validateValues();
95 public:
96 int readAllValues(char *filename);
97 void print();
98 inline int getPageSize() { return cVal.pageSize; }
99 inline int getMaxProcs() { return cVal.maxProcs; }
100 inline long getMaxSysDbSize() { return cVal.maxSysSize; }
101 inline long getMaxDbSize() { return cVal.maxDbSize; }
102 inline int getSysDbKey() { return cVal.sysDbKey; }
103 inline int getUserDbKey() { return cVal.userDbKey; }
104 inline char* getLogFile() { return cVal.logFile; }
105 inline char* getDbFile() { return cVal.dbFile; }
106 inline long getMapAddress() { return cVal.mapAddr; }
107 inline int getMutexSecs() { return cVal.mutexSecs; }
108 inline int getMutexUSecs() { return cVal.mutexUSecs; }
109 inline int getMutexRetries() { return cVal.mutexRetries; }
110 inline int getLockSecs() { return cVal.lockSecs; }
111 inline int getLockUSecs() { return cVal.lockUSecs; }
112 inline int getLockRetries() { return cVal.lockRetries; }
113 inline int getCacheID(){ return cVal.cacheId;}
114 inline bool useCache() { return cVal.isCache; }
115 inline char* getDSN() { return cVal.dsn; }
116 inline char* getTableConfigFile() { return cVal.tableConfigFile; }
117 inline bool useReplication() { return cVal.isReplication; }
118 inline char* getReplConfigFile() { return cVal.replConfigFile; }
119 inline long getMaxLogStoreSize() { return cVal.logStoreSize; }
120 inline int getNetworkID() { return cVal.networkID; }
121 inline int getCacheNetworkID() { return cVal.cacheNetworkID; }
122 inline int getNetworkResponseTimeout() { return cVal.nwResponseTimeout; }
123 inline int getNetworkConnectTimeout() { return cVal.nwConnectTimeout; }
124 inline bool useTwoWayCache() { return cVal.isTwoWay; }
125 inline int getCacheWaitSecs() { return cVal.cacheWaitSecs; }
128 class Conf
130 public:
131 static Config config;
135 #endif