Feature Request ID: 1669025
[csql.git] / include / DatabaseManagerImpl.h
blob23e935b329c205423e6dd5ae0356249bdbeffcb9
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>
23 class Database;
24 class SessionImpl;
25 class TableDef;
26 class Table;
27 class FieldNameList;
28 class ChunkIterator;
29 class Chunk;
30 class TransactionManager;
33 class DatabaseManagerImpl : public DatabaseManager
35 private:
36 Database* systemDatabase_;
37 //pointer to system Database
39 Database* db_;
40 //pointer to database
42 LockManager *lMgr_;
44 TransactionManager *tMgr_;
46 //only SessionImpl creates object of this class
47 DatabaseManagerImpl() { systemDatabase_ = NULL; tMgr_ = NULL; lMgr_ = NULL; db_ = NULL; }
48 ~DatabaseManagerImpl();
50 DbRetVal openSystemDatabase();
51 DbRetVal closeSystemDatabase();
52 ChunkIterator getSystemTableIterator(CatalogTableID id);
53 Chunk* getSystemTableChunk(CatalogTableID id);
55 void createLockManager();
56 void createTransactionManager();
58 Chunk* createUserChunk(size_t size = 0);
59 DbRetVal deleteUserChunk(Chunk *chunk);
62 DbRetVal createHashIndex(const char *indName, const char *tableName,
63 FieldNameList &fldList, int bucketSize);
64 void initHashBuckets(Bucket *buck, int bucketSize);
67 public:
69 Database* db() { return db_; }
70 Database* sysDb() { return systemDatabase_; }
71 void setSysDb(Database *db) { systemDatabase_ = db; }
72 void setDb(Database *db) { db_ = db; }
74 TransactionManager* txnMgr() { return tMgr_; }
75 LockManager* lockMgr() { return lMgr_; }
77 //for user database file there is no limit for the number
78 //of tables or chunks
79 DbRetVal createDatabase(const char *name, size_t size);
80 DbRetVal deleteDatabase(const char *name);
82 DbRetVal openDatabase(const char *name);
83 void closeDatabase();
87 DbRetVal createTable(const char *name, TableDef &def);
88 DbRetVal dropTable(const char *name);
89 Table* openTable(const char *name);
90 void closeTable(Table *table);
91 DbRetVal createIndex(const char *indName, IndexInitInfo *info);
92 DbRetVal dropIndex(const char *name);
95 friend class SessionImpl;
97 #endif