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