CollArray.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_COLL_ARRAY_H
00026 #define _EYEDB_COLL_ARRAY_H
00027 
00028 namespace eyedb {
00029 
00038   class CollArray : public Collection {
00039 
00040     // ----------------------------------------------------------------------
00041     // CollArray Interface
00042     // ----------------------------------------------------------------------
00043   public:
00052     CollArray(Database *db, const char *n, Class *mc = NULL,
00053               Bool isref = True,
00054               const IndexImpl *idximpl = 0);
00055 
00064     CollArray(Database *db, const char *n, Class *mc, int dim,
00065               const IndexImpl *idximpl = 0);
00066 
00071     CollArray(const CollArray &o);
00072 
00077     CollArray& operator=(const CollArray &o);
00078 
00083     virtual Object *clone() const {return new CollArray(*this);}
00084   
00091     Status insert(const Value &value, Bool noDup = False);
00092 
00099     Status suppress(const Value &value, Bool checkFirst = False);
00100 
00106     Status insertAt(Collection::ItemId id, const Value &value);
00107 
00113     Status append(const Value &value);
00114 
00120     Status suppressAt(Collection::ItemId id);
00121 
00128     Status retrieveAt(Collection::ItemId id, Value &value) const;
00129 
00136     Status retrieveAt(Collection::ItemId id, Oid &item_oid) const;
00137 
00145     Status retrieveAt(Collection::ItemId id, ObjectPtr &o,
00146                       const RecMode *recmode = RecMode::NoRecurs) const;
00147 
00155     Status retrieveAt(Collection::ItemId id, Object *&o,
00156                       const RecMode *recmode = RecMode::NoRecurs) const;
00157 
00162     virtual CollArray *asCollArray() {return this;}
00163 
00168     virtual const CollArray *asCollArray() const {return this;}
00169 
00170     Status getImplStats(std::string &, std::string &, Bool dspImpl = True,
00171                         Bool full = False, const char *indent = "");
00172     Status getImplStats(IndexStats *&, IndexStats *&);
00173 
00174     Status simulate(const IndexImpl &, std::string &, std::string &,
00175                     Bool dspImpl = True, Bool full = False,
00176                     const char *indent = "");
00177     Status simulate(const IndexImpl &, IndexStats *&, IndexStats *&);
00178 
00179     virtual void garbage();
00180 
00181     // ----------------------------------------------------------------------
00182     // CollArray Private Part
00183     // ----------------------------------------------------------------------
00184   private:
00185     ValueCache *read_arr_cache;
00186 
00187     void init();
00188     const char *getClassName() const;
00189     CollArray(const char *, Class *,
00190               const Oid&, const Oid&, int,
00191               int, int,  const IndexImpl *, Object *,
00192               Bool, Bool, Data, Size);
00193     friend class CollectionPeer;
00194 
00195     // ----------------------------------------------------------------------
00196     // CollArray Restricted Access (conceptually private)
00197     // ----------------------------------------------------------------------
00198   public:
00199     CollArray(const char *, Class * = NULL, Bool = True,
00200               const IndexImpl * = 0);
00201     CollArray(const char *, Class *, int,
00202               const IndexImpl * = 0);
00203 
00204     Status insert_p(const Oid &item_oid, Bool noDup = False);
00205     Status insert_p(const Object *item_o, Bool noDup = False);
00206     Status insert_p(Data val, Bool noDup = False, Size size = defaultSize);
00207     Status suppress_p(const Oid &item_oid, Bool checkFirst = False);
00208     Status suppress_p(const Object *item_o, Bool checkFirst = False);
00209     Status suppress_p(Data data, Bool checkFirst = False, Size size = defaultSize);
00210     Status insertAt_p(Collection::ItemId id, const Oid &item_oid);
00211     Status insertAt_p(Collection::ItemId id, const Object *item_o);
00212     Status insertAt_p(Collection::ItemId id, Data val, Size size = defaultSize);
00213     Status append_p(const Oid &item_oid, Bool noDup = False);
00214     Status append_p(const Object *item_o, Bool noDup = False);
00215     Status append_p(Data data, Bool noDup = False, Size size = defaultSize);
00216     Status retrieveAt_p(Collection::ItemId id, Data data, Size size = defaultSize) const;
00217 
00218   };
00219 
00220   class CollArrayPtr : public CollectionPtr {
00221 
00222   public:
00223     CollArrayPtr(CollArray *o = 0) : CollectionPtr(o) { }
00224 
00225     CollArray *getCollArray() {return dynamic_cast<CollArray *>(o);}
00226     const CollArray *getCollArray() const {return dynamic_cast<CollArray *>(o);}
00227 
00228     CollArray *operator->() {return dynamic_cast<CollArray *>(o);}
00229     const CollArray *operator->() const {return dynamic_cast<CollArray *>(o);}
00230   };
00231 
00232   typedef std::vector<CollArrayPtr> CollArrayPtrVector;
00233 
00238 }
00239 
00240 #endif

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