StructClass.cc

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 #include "eyedb_p.h"
00026 #include <iostream>
00027 
00028 namespace eyedb {
00029 
00030 extern void oqlctbMake(Object **);
00031 extern void utilsMake(Object **);
00032 
00033 //
00034 // StructClass methods
00035 //
00036 
00037 StructClass::StructClass(const char *s, Class *p) :
00038 AgregatClass(s, p)
00039 {
00040   parent = (p ? p : Struct_Class);
00041   setClass(StructClass_Class);
00042   type = _StructClass_Type;
00043 }
00044 
00045 StructClass::StructClass(const char *s, const Oid *poid) :
00046 AgregatClass(s, poid)
00047 {
00048   parent = 0;
00049   setClass(StructClass_Class);
00050   type = _StructClass_Type;
00051 }
00052 
00053 StructClass::StructClass(Database *_db, const char *s,
00054                                Class *p) : AgregatClass(_db, s, p)
00055 {
00056   parent = (p ? p : Struct_Class);
00057   setClass(StructClass_Class);
00058   type = _StructClass_Type;
00059 }
00060 
00061 StructClass::StructClass(Database *_db, const char *s,
00062                                const Oid *poid) : AgregatClass(_db, s, poid)
00063 {
00064   parent = 0;
00065   setClass(StructClass_Class);
00066   type = _StructClass_Type;
00067 }
00068 
00069 // should be moved to a .h
00070 extern void sysclsMake(Object **);
00071 
00072 Object *StructClass::newObj(Database *_db) const
00073 {
00074   if (!idr_objsz)
00075     return 0;
00076 
00077   Struct *t = new Struct(_db);
00078 
00079   ObjectPeer::make(t, this, 0, _Struct_Type, idr_objsz,
00080                       idr_psize, idr_vsize);
00081   newObjRealize(t);
00082 
00083   //#ifndef OPTCONSAPP
00084 
00085   // 6/10/01: reconnected the following code because of a the following bug:
00086   // (select Person.birthdate).toString() does not construct a Date because
00087   // the consapp facility of Database is not used.
00088   if (!ObjectPeer::isGRTObject(t)) {
00089     sysclsMake((Object **)&t); // should better be in ObjectPeer::make!!
00090     oqlctbMake((Object **)&t); // should better be in ObjectPeer::make!!
00091     utilsMake((Object **)&t); // should better be in ObjectPeer::make!!
00092   }
00093   return t;
00094 }
00095 
00096 StructClass::StructClass(const Oid &_oid, const char *_name)
00097   : AgregatClass(_oid, _name)
00098 {
00099   type = _StructClass_Type;
00100 }
00101 
00102 Status
00103 StructClass::loadComplete(const Class *cl)
00104 {
00105   assert(cl->asStructClass());
00106   Status s = Class::loadComplete(cl);
00107   if (s) return s;
00108   return Success;
00109 }
00110 
00111 Object *StructClass::newObj(Data data, Bool _copy) const
00112 {
00113   if (!idr_objsz)
00114     return 0;
00115 
00116   Struct *t = new Struct();
00117 
00118   ObjectPeer::make(t, this, data, _Struct_Type, idr_objsz,
00119                       idr_psize, idr_vsize, _copy);
00120   newObjRealize(t);
00121 
00122   //#ifndef OPTCONSAPP
00123   // see previous newObj method comments
00124   if (!ObjectPeer::isGRTObject(t)) {
00125     sysclsMake((Object **)&t);
00126     oqlctbMake((Object **)&t); // should better be in ObjectPeer::make!!
00127     utilsMake((Object **)&t); // should better be in ObjectPeer::make!!
00128   }
00129   //#endif
00130   return t;
00131 }
00132 }

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