fixing readmes in examples
[csql.git] / include / DatabaseManagerImpl.h
blobedbb09bee2926a3a4f0f9e1c078ad8a9a7b51975
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 DATABASE_MANAGER_IMPL_H
17 #define DATABASE_MANAGER_IMPL_H
18 #include<os.h>
19 #include<CatalogTables.h>
20 #include<Lock.h>
21 #include<DatabaseManager.h>
22 #include<Process.h>
23 //Note::DatabaseManagerImpl is used to hide functionalites from normal database user.
24 //User is exposed to DatabaseManagerImpl, for our tools we shall type cast DatabaseManager
25 //to DatabaseManagerImpl to retreive internal information such as db statistics, etc
26 class Database;
27 class SessionImpl;
28 class TableDef;
29 class Table;
30 class FieldNameList;
31 class ChunkIterator;
32 class Chunk;
33 class TransactionManager;
34 class CSqlProcInfo
36 public:
37 CSqlProcInfo() { sysDbAttachAddr = userDbAttachAddr = NULL;}
38 void *sysDbAttachAddr;
39 void *userDbAttachAddr;
42 //Global object
43 static CSqlProcInfo csqlProcInfo;
45 class DatabaseManagerImpl : public DatabaseManager
47 private:
48 Database* systemDatabase_;
49 //pointer to system Database
51 Database* db_;
52 //pointer to database
54 LockManager *lMgr_;
56 TransactionManager *tMgr_;
59 ProcessManager *pMgr_;
60 int procSlot;
62 //only SessionImpl creates object of this class
63 DatabaseManagerImpl() { systemDatabase_ = NULL; tMgr_ = NULL; lMgr_ = NULL;
64 pMgr_ = NULL; db_ = NULL; }
65 ~DatabaseManagerImpl();
67 DbRetVal openSystemDatabase();
68 DbRetVal closeSystemDatabase();
69 ChunkIterator getSystemTableIterator(CatalogTableID id);
70 Chunk* getSystemTableChunk(CatalogTableID id);
72 void createLockManager();
73 void createTransactionManager();
75 Chunk* createUserChunk(size_t size = 0);
76 DbRetVal deleteUserChunk(Chunk *chunk);
79 DbRetVal createHashIndex(const char *indName, const char *tableName,
80 FieldNameList &fldList, int bucketSize, bool isUnique, bool isPrimary = false);
81 void initHashBuckets(Bucket *buck, int bucketSize);
83 DbRetVal dropIndexInt(const char *name, bool takeLock);
85 public:
87 Database* db() { return db_; }
88 Database* sysDb() { return systemDatabase_; }
89 void setSysDb(Database *db) { systemDatabase_ = db; }
90 void setDb(Database *db) { db_ = db; }
92 void setProcSlot();
93 TransactionManager* txnMgr() { return tMgr_; }
94 LockManager* lockMgr() { return lMgr_; }
96 //for user database file there is no limit for the number
97 //of tables or chunks
98 DbRetVal createDatabase(const char *name, size_t size);
99 DbRetVal deleteDatabase(const char *name);
101 DbRetVal openDatabase(const char *name);
102 DbRetVal closeDatabase();
106 DbRetVal createTable(const char *name, TableDef &def);
107 DbRetVal dropTable(const char *name);
108 Table* openTable(const char *name);
109 void closeTable(Table *table);
110 DbRetVal createIndex(const char *indName, IndexInitInfo *info);
111 DbRetVal dropIndex(const char *name);
112 List getAllTableNames();
114 DbRetVal registerThread();
115 DbRetVal deregisterThread();
116 bool isAnyOneRegistered();
117 void printUsageStatistics();
118 void printDebugLockInfo();
119 void printDebugTransInfo();
120 void printDebugChunkInfo();
121 void printDebugProcInfo();
122 DbRetVal printIndexInfo(char *name);
123 friend class SessionImpl;
125 #endif