CollectionClass.h

00001 /* 
00002    EyeDB Object Database Management System
00003    Copyright (C) 1994-2008 SYSRA
00004    
00005    EyeDB is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009    
00010    EyeDB is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014    
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with this library; if not, write to the Free Software
00017    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA 
00018 */
00019 
00020 /*
00021    Author: Eric Viara <viara@sysra.com>
00022 */
00023 
00024 
00025 #ifndef _EYEDB_COLLECTION_CLASS_H
00026 #define _EYEDB_COLLECTION_CLASS_H
00027 
00028 namespace eyedb {
00029 
00038   class CollectionClass : public Class {
00039 
00040     // ----------------------------------------------------------------------
00041     // CollectionClass Interface
00042     // ----------------------------------------------------------------------
00043   public:
00049     const char *getCName(Bool useAsRef = False) const;
00050 
00058     Class *getCollClass(Bool *isref = NULL, eyedblib::int16 *dim = NULL, eyedblib::int16 *item_size = NULL);
00059 
00067     const Class *getCollClass(Bool *isref = NULL, eyedblib::int16 *dim = NULL, eyedblib::int16 *item_size = NULL) const;
00068 
00073     int getItemSize() const {return item_size;}
00074 
00079     Status getStatus() const {return _status;}
00080 
00085     Status create();
00086 
00091     Status update();
00092 
00098     Status remove(const RecMode *recmode = RecMode::NoRecurs);
00099 
00107     Status trace(FILE* fd = stdout, unsigned int flags = 0, const RecMode *recmode = RecMode::FullRecurs) const;
00108 
00115     static Status make(Database *db, Class **cls);
00116 
00117     Status generateCode_C(Schema *, const char *prefix,
00118                           const GenCodeHints &,
00119                           const char *stubs,
00120                           FILE *, FILE *, FILE *, FILE *, FILE *, FILE *);
00121     Status generateCode_Java(Schema *, const char *prefix, 
00122                              const GenCodeHints &, FILE *);
00123     //Bool compare_perform(const Class *) const;
00124     Bool compare_perform(const Class *cl,
00125                          Bool compClassOwner,
00126                          Bool compNum,
00127                          Bool compName,
00128                          Bool inDepth) const;
00129 
00130     virtual const char *getPrefix() const {return NULL;}
00131     virtual const char *getCSuffix() const {return "NULL";}
00132 
00137     virtual CollectionClass *asCollectionClass() {return this;}
00138 
00143     virtual const CollectionClass *asCollectionClass() const {return this;}
00144 
00150     virtual Status setName(const char *s);
00151 
00152     // ----------------------------------------------------------------------
00153     // CollectionClass Protected Part
00154     // ----------------------------------------------------------------------
00155   protected:
00156     Class *coll_class;
00157     Bool isref;
00158     eyedblib::int16 dim;
00159     Oid cl_oid;
00160     eyedblib::int16 item_size;
00161     Status _status;
00162 
00163     CollectionClass(Class *, Bool, const char *);
00164     CollectionClass(Class *, int, const char *);
00165     CollectionClass(const CollectionClass &);
00166     CollectionClass& operator=(const CollectionClass &);
00167 
00168     static const char *make_name(const char *, Class*, Bool, int, Bool);
00169     static CollectionClass *get(const char *, Class *, Bool, int);
00170     static void set(const char *, Class *, Bool, int,
00171                     CollectionClass *);
00172 
00173     int genODL(FILE *fd, Schema *) const;
00174 
00175     // ----------------------------------------------------------------------
00176     // CollectionClass Private Part
00177     // ----------------------------------------------------------------------
00178   private:
00179     static LinkedList *mcoll_list;
00180     Status trace_realize(FILE*, int, unsigned int, const RecMode *) const;
00181     Status check(Class *_coll_class, Bool _isref, int _dim);
00182     void copy_realize(const CollectionClass &);
00183 
00184     // ----------------------------------------------------------------------
00185     // CollectionClass Restricted Access (conceptually private)
00186     // ----------------------------------------------------------------------
00187   public:
00188     static void init();
00189     static void _release();
00190     void invalidateCollClassOid();
00191 
00192     // ----------------------------------------------------------------------
00193     // CollectionClass Restricted Access (conceptually private)
00194     // ----------------------------------------------------------------------
00195   public:
00196     CollectionClass(const Oid&, const char *);
00197     virtual Status loadComplete(const Class *);
00198   };
00199 
00200   class CollectionClassPtr : public ClassPtr {
00201 
00202   public:
00203     CollectionClassPtr(CollectionClass *o = 0) : ClassPtr(o) { }
00204 
00205     CollectionClass *getCollectionClass() {return dynamic_cast<CollectionClass *>(o);}
00206     const CollectionClass *getCollectionClass() const {return dynamic_cast<CollectionClass *>(o);}
00207 
00208     CollectionClass *operator->() {return dynamic_cast<CollectionClass *>(o);}
00209     const CollectionClass *operator->() const {return dynamic_cast<CollectionClass *>(o);}
00210   };
00211 
00212   typedef std::vector<CollectionClassPtr> CollectionClassPtrVector;
00213 
00218 }
00219 
00220 #endif

Generated on Mon Dec 22 18:15:52 2008 for eyedb by  doxygen 1.5.3