1 /***************************************************************************
2 * Copyright (C) 2007 by www.databasecache.com *
3 * Contact: praba_tuty@databasecache.com *
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. *
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. *
15 ***************************************************************************/
26 * @class FieldNameList
28 * @brief Field name list used to specify composite key while creating index. <br/>
29 * @author Prabakaran Thirumalai
36 FieldNameList() { head
= iter
= NULL
; }
37 ~FieldNameList() { } //TODO::Remove all elements from the list
38 char *nextFieldName();
39 void resetIter(){ iter
= head
; }
42 /** appends field name to the list
43 * @param name field name
46 DbRetVal
append(const char *name
);
48 /** removes field name from the list
49 * @param name field name
52 DbRetVal
remove(const char *name
);
63 * @brief Represents table definition used to create the table.
64 * Encapsulates the information or schema definition of a table.For Example say if <br/>
65 * we need to create table with two fields, call addField method with necessary parameters<br/>
66 * twice. Passed as argument to createTable method of DatabaseManager to create table.<br/>
67 * @author Prabakaran Thirumalai
77 /** adds a field to the schema definition.
78 * @param name field name
79 * @param type data type of the field
80 * @param length size of the field. used in case of char and binary data types.
81 * @param defaultValue default value for the field. It is currently limited to 32 bytes.
82 * @param notNull whether the field can be null
83 * @param isPrimary whether the field is primary key( not null + unique)
86 int addField(const char *name
, DataType type
= typeUnknown
, size_t
87 length
= 0, const void *defaultValue
= 0, bool notNull
= false,
88 bool isPrimary
= false);
90 /** removes a field from the schema definition
91 * @param name field name
94 int dropField(const char *name
);
96 /** returns the total number of fields in this table definition
97 * @return int no of fields
101 /** returns the total tuple size in bytes.
102 * @return size_t tuple size
104 size_t getTupleSize();
106 //Internal method used to iterate and get information stored
107 //in this table definition.
108 FieldIterator
getFieldIterator(){ return fldList
.getIterator(); }
115 hashIndex
= 0, /**<hash index*/
116 treeIndex
/**<tree index*/
120 * @class IndexInitInfo
122 * @brief Represents index definition used to create index.
123 * Encapsulates the information or definition of an index.<br/>
124 * @author Prabakaran Thirumalai
129 char tableName
[IDENTIFIER_LENGTH
]; /**<tablename*/
130 FieldNameList list
; /**<field name list*/
131 IndexType indType
; /**<index type*/
132 IndexInitInfo() { indType
= hashIndex
; }
133 ~IndexInitInfo() {list
.removeAll();}
137 * @class HashIndexInitInfo
139 * @brief Represents hash index definition used to create index.
140 * Encapsulates the information or definition of hash index.<br/>
141 * @author Prabakaran Thirumalai
143 class HashIndexInitInfo
: public IndexInitInfo
146 int bucketSize
; /**<bucket size*/
147 HashIndexInitInfo() { bucketSize
= 1009; }