Main Page   Class Hierarchy   Compound List   File List   Compound Members  

container.h

00001 //-< CONTAINER.H >---------------------------------------------------*--------*
00002 // FastDB                    Version 1.0         (c) 1999  GARRET    *     ?  *
00003 // (Main Memory Database Management System)                          *   /\|  *
00004 //                                                                   *  /  \  *
00005 //                          Created:     05-Nov-2002  K.A. Knizhnik  * / [] \ *
00006 //                          Last update: 05-Nov-2002  K.A. Knizhnik  * GARRET *
00007 //-------------------------------------------------------------------*--------*
00008 // T-Tree object container
00009 //-------------------------------------------------------------------*--------*
00010 
00011 #ifndef __CONTAINER_H__
00012 #define __CONTAINER_H__
00013 
00014 BEGIN_FASTDB_NAMESPACE
00015 
00019 enum SpatialSearchType { 
00020     SPATIAL_SEARCH_EQUAL,
00021     SPATIAL_SEARCH_OVERLAPS,
00022     SPATIAL_SEARCH_SUPERSET,
00023     SPATIAL_SEARCH_PROPER_SUPERSE,
00024     SPATIAL_SEARCH_SUBSET,
00025     SPATIAL_SEARCH_PROPER_SUBSET
00026 };
00027 
00032 class FASTDB_DLL_ENTRY dbAnyContainer : public dbAnyReference {
00033   protected:
00034     dbFieldDescriptor* fd;
00035 
00036     void create(dbDatabase* db);
00037     void purge(dbDatabase* db);
00038     void free(dbDatabase* db);
00039     void add(dbDatabase* db, dbAnyReference const& ref);
00040     void remove(dbDatabase* db, dbAnyReference const& ref);
00041     int  search(dbAnyCursor& cursor, void const* from, void const* till);
00042     int  prefixSearch(dbAnyCursor& cursor, char const* key);
00043     int  spatialSearch(dbAnyCursor& cursor, rectangle const& r, SpatialSearchType type);
00044 
00045     dbAnyContainer(char const* fieldName, dbTableDescriptor& desc);
00046 };
00047 
00048 
00052 template<class T>
00053 class dbContainer : public dbAnyContainer {
00054   public:
00062     int search(dbCursor<T>& cursor, void const* from, void const* till) {
00063         return dbAnyContainer::search(cursor, from, till);
00064     }
00071     int search(dbCursor<T>& cursor, void const* key) {
00072         return dbAnyContainer::search(cursor, key, key);
00073     }
00074 
00081     int prefixSearch(dbCursor<T>& cursor, char const* key) {
00082         return dbAnyContainer::prefixSearch(cursor, key);
00083     }
00084 
00090     int search(dbCursor<T>& cursor) {
00091         return dbAnyContainer::search(cursor, NULL, NULL);
00092     }
00093 
00101     int spatialSearch(dbCursor<T>& cursor, rectangle const& r, SpatialSearchType type) { 
00102         return dbAnyContainer::spatialSearch(cursor, r, type);
00103     }
00104 
00108     void create() {
00109         dbAnyContainer::create(T::dbDescriptor.getDatabase());
00110     }
00111 
00115     void purge() {
00116         dbAnyContainer::purge(T::dbDescriptor.getDatabase());
00117     }
00118 
00122     void free() {
00123         dbAnyContainer::free(T::dbDescriptor.getDatabase());
00124     }
00125 
00130     void add(dbReference<T> const& ref) {
00131         dbAnyContainer::add(T::dbDescriptor.getDatabase(), ref);
00132     }
00133 
00138     void remove(dbReference<T> const& ref) {
00139         dbAnyContainer::remove(T::dbDescriptor.getDatabase(), ref);
00140     }
00141 
00146     dbContainer(const char* fieldName) : dbAnyContainer(fieldName, T::dbDescriptor) {}
00147     
00152     void create(dbDatabase* db) {
00153         dbAnyContainer::create(db);
00154     }
00155 
00160     void purge(dbDatabase* db) {
00161         dbAnyContainer::purge(db);
00162     }
00163 
00168     void free(dbDatabase* db) {
00169         dbAnyContainer::free(db);
00170     }
00171 
00177     void add(dbDatabase* db, dbReference<T> const& ref) {
00178         dbAnyContainer::add(db, ref);
00179     }
00180 
00186     void remove(dbDatabase* db, dbReference<T> const& ref) {
00187         dbAnyContainer::remove(db, ref);
00188     }
00189 
00195     dbContainer(dbDatabase* db, const char* fieldName) 
00196     : dbAnyContainer(fieldName, *db->lookupTable(&T::dbDescriptor)) {}
00197 };
00198 
00199 END_FASTDB_NAMESPACE
00200 
00201 #endif
00202 
00203 
00204 
00205 

Generated on Mon Oct 23 13:23:58 2006 for FastDB by doxygen1.2.18