Union.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 //
00026 // Union methods
00027 // 
00028 
00029 #include "eyedb_p.h"
00030 #include <iostream>
00031 
00032 namespace eyedb {
00033 
00034   const Attribute *Union::setCurrentItem(const Attribute *ni)
00035   {
00036     const Attribute *old = item;
00037     item = ni;
00038 
00039     Offset offset = IDB_OBJ_HEAD_SIZE;
00040     Size alloc_size = idr->getSize();
00041     Data data = idr->getIDR();
00042 
00043     if (item)
00044       {
00045         eyedblib::int16 num = item->getNum();
00046         int16_code(&data, &offset, &alloc_size, &num);
00047       }
00048     else
00049       {
00050         eyedblib::int16 k = -1;
00051         int16_code(&data, &offset, &alloc_size, &k);
00052       }
00053 
00054     //  printf("SETCURRENTITEM %s\n", ni->getName());
00055     return old;
00056   }
00057 
00058   const Attribute *Union::getCurrentItem() const
00059   {
00060     /*
00061       if (item)
00062       printf("  GETCURRENTITEM %s\n", item->getName());
00063     */
00064     return item;
00065   }
00066 
00067   const Attribute *Union::decodeCurrentItem(const Class *cls,
00068                                             Data idr)
00069   {
00070     eyedblib::int16 num;
00071     const Attribute *item;
00072 
00073     Offset offset = IDB_OBJ_HEAD_SIZE;
00074     int16_decode(idr, &offset, &num);
00075 
00076     if (num >= 0)
00077       item = ((AgregatClass *)cls)->getAttributes()[num];
00078     else
00079       item = 0;
00080 
00081     return item;
00082   }
00083 
00084   const Attribute *Union::decodeCurrentItem()
00085   {
00086     item = decodeCurrentItem(getClass(), idr->getIDR());
00087     return item;
00088   }
00089 }

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