/home/tetron/hack/vos/libs/vos/vos/vobjectiter.hh
Go to the documentation of this file.00001 #ifndef _VOBJECTITER_HH_
00002 #define _VOBJECTITER_HH_
00003
00004 #include <vos/vos/identity.hh>
00005 #include <vos/vos/iterator.hh>
00006
00007 namespace VUtil {
00008 template<> inline void iteratorReleaseItem(VOS::Vobject** v)
00009 {
00010 (*v)->release();
00011 }
00012 }
00013
00014 namespace VOS {
00015
00016
00017
00018 class VOS_API VobjectIterator : public VUtil::Iterator<Vobject*>
00019 {
00020 public:
00021 VobjectIterator() : VUtil::Iterator<Vobject*>() { }
00022 VobjectIterator(const VobjectIterator& i) : VUtil::Iterator<Vobject*>(i) { }
00023 VobjectIterator(const std::set<Identity*> ids,
00024 const std::set<Group*> grps) {
00025 items->resize(ids.size() + grps.size());
00026 int c = 0;
00027 for(std::set<Identity*>::const_iterator i = ids.begin();
00028 i != ids.end();
00029 i++)
00030 {
00031 (*i)->acquire();
00032 (*items)[c] = (*i);
00033 c++;
00034 }
00035 for(std::set<Group*>::const_iterator i = grps.begin();
00036 i != grps.end();
00037 i++)
00038 {
00039 (*i)->acquire();
00040 (*items)[c] = (*i);
00041 c++;
00042 }
00043 }
00044 VUtil::vRef<Vobject> operator*() {
00045 if(pos < items->size()) return VUtil::vRef<Vobject>((*items)[pos], true);
00046 else return VUtil::vRef<Vobject>();
00047 }
00048 };
00049 }
00050
00051 namespace VUtil {
00052 template<> inline void iteratorReleaseItem(VOS::MetaObject** v)
00053 {
00054 (*v)->release();
00055 }
00056 }
00057
00058 namespace VOS {
00059
00060
00061
00062 class VOS_API MetaObjectIterator : public VUtil::Iterator<MetaObject*>
00063 {
00064 public:
00065 MetaObjectIterator() : VUtil::Iterator<MetaObject*>() { }
00066 MetaObjectIterator(const MetaObjectIterator& i) : VUtil::Iterator<MetaObject*>(i) { }
00067 MetaObjectIterator(const std::vector< std::pair<std::string, MetaObject*> > mobs) {
00068 items->resize(mobs.size());
00069 int c = 0;
00070 for(std::vector< std::pair<std::string, MetaObject*> >::const_iterator i = mobs.begin();
00071 i != mobs.end();
00072 i++)
00073 {
00074 (*i).second->acquire();
00075 (*items)[c] = (*i).second;
00076 c++;
00077 }
00078 }
00079 VUtil::vRef<MetaObject> operator*() {
00080 if(pos < items->size()) return VUtil::vRef<MetaObject>((*items)[pos], true);
00081 else return VUtil::vRef<MetaObject>();
00082 }
00083 };
00084 };
00085
00086 #endif