Union.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_UNION_H
00026 #define _EYEDB_UNION_H
00027 
00028 namespace eyedb {
00029 
00038   class Union : public Agregat {
00039 
00040     // ----------------------------------------------------------------------
00041     // Union Interface
00042     // ----------------------------------------------------------------------
00043   public:
00049     Union(Database *_db = 0, const Dataspace *_dataspace = 0) :
00050       Agregat(_db, _dataspace) {item = 0;}
00051 
00056     Union(const Union &o) : Agregat(o) {}
00057 
00063     Union(const Union *o, Bool share = False) : Agregat(o, share)
00064     {item = 0;}
00065 
00070     virtual Object *clone() const {return new Union(*this);}
00071 
00072 
00078     const Attribute *setCurrentItem(const Attribute *ni);
00079 
00084     const Attribute *getCurrentItem() const;
00085 
00090     const Attribute *decodeCurrentItem();
00091 
00098     static const Attribute *decodeCurrentItem(const Class *cls, Data idr);
00099 
00100 
00105     virtual Union *asUnion() {return this;}
00106 
00111     virtual const Union *asUnion() const {return this;}
00112 
00113 
00114     // ----------------------------------------------------------------------
00115     // Union Protected Part
00116     // ----------------------------------------------------------------------
00117   protected:
00118     void initialize(Database *_db) {
00119       Agregat::initialize(_db);
00120     }
00121 
00122     // ----------------------------------------------------------------------
00123     // Union Private Part
00124     // ----------------------------------------------------------------------
00125   private:
00126     const Attribute *item;
00127   };
00128 
00129   class UnionPtr : public AgregatPtr {
00130 
00131   public:
00132     UnionPtr(Union *o = 0) : AgregatPtr(o) { }
00133 
00134     Union *getUnion() {return dynamic_cast<Union *>(o);}
00135     const Union *getUnion() const {return dynamic_cast<Union *>(o);}
00136 
00137     Union *operator->() {return dynamic_cast<Union *>(o);}
00138     const Union *operator->() const {return dynamic_cast<Union *>(o);}
00139   };
00140 
00141   typedef std::vector<UnionPtr> UnionPtrVector;
00142 
00147 }
00148 
00149 #endif

Generated on Mon Dec 22 18:16:11 2008 for eyedb by  doxygen 1.5.3