ClassIterator.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 
00027 namespace eyedb {
00028 
00029 
00030   ClassIterator::ClassIterator(const Class *cls, Bool subclass)
00031   {
00032     init(cls, subclass);
00033   }
00034 
00035   ClassIterator::ClassIterator(const ClassPtr &cls_ptr, Bool subclass)
00036   {
00037     init(cls_ptr.getClass(), subclass);
00038   }
00039 
00040   void ClassIterator::init(const Class *cls, Bool subclass)
00041   {
00042     q = new Iterator(const_cast<Class*>(cls), subclass);
00043     status = q->getStatus();
00044     if (status) {
00045       delete q;
00046       q = 0;
00047       // 19/09/05: cannot throw in a constructor
00048       //throw *status;
00049     }
00050   }
00051 
00052   Bool ClassIterator::next(Oid &oid)
00053   {
00054     if (status)
00055       throw *status;
00056     Bool found;
00057     status = q->scanNext(found, oid);
00058     if (status)
00059       throw *status;
00060     return found;
00061   }
00062 
00063   Bool ClassIterator::next(ObjectPtr &o_ptr, const RecMode *rcm)
00064   {
00065     Object *o = 0;
00066     Bool b = next(o, rcm);
00067     o_ptr = o;
00068     return b;
00069   }
00070 
00071   Bool ClassIterator::next(Object *&o, const RecMode *rcm)
00072   {
00073     if (status)
00074       throw *status;
00075     Bool found;
00076     o = 0;
00077     status = q->scanNext(found, o, rcm);
00078     if (status)
00079       throw *status;
00080     return found;
00081   }
00082 
00083   Bool ClassIterator::next(Value &v)
00084   {
00085     if (status)
00086       throw *status;
00087     Bool found;
00088     status = q->scanNext(found, v);
00089     if (status) throw *status;
00090     return found;
00091   }
00092 
00093 
00094   ClassIterator::~ClassIterator()
00095   {
00096     delete q;
00097   }
00098 
00099 }

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