00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __OBJITER_H__
00020 #define __OBJITER_H__
00021
00022 #include "iutil/object.h"
00023
00028 #define CS_DECLARE_OBJECT_ITERATOR(NAME,INTERFACE) \
00029 class NAME : public csTypedObjectIterator \
00030 { \
00031 protected: \
00032 virtual void GetRequestedInterface (scfInterfaceID &id, int &ver) const \
00033 { id = scfGetID_##INTERFACE (); ver = VERSION_##INTERFACE; } \
00034 public: \
00035 inline NAME (iObject *Parent) : csTypedObjectIterator (Parent) \
00036 { FetchObject (); } \
00037 inline INTERFACE *Get () \
00038 { return (INTERFACE*)CurrentTypedObject; } \
00039 };
00040
00041 class csTypedObjectIterator
00042 {
00043 protected:
00044 iObjectIterator *iter;
00045 iBase *CurrentTypedObject;
00046
00047 void FetchObject ();
00048 virtual void GetRequestedInterface (scfInterfaceID &id, int &ver) const = 0;
00049
00050 public:
00051
00052 csTypedObjectIterator (iObject *Parent);
00053
00054 virtual ~csTypedObjectIterator ();
00055
00056
00057 inline bool Next();
00058
00059 inline void Reset();
00060
00061 inline iObject *GetObject () const;
00062
00063 inline iObject *GetParentObj() const;
00064
00065 inline bool IsFinished () const;
00066
00067 inline bool FindName (const char* name);
00068 };
00069
00070 inline bool csTypedObjectIterator::Next()
00071 { bool r = iter->Next (); FetchObject (); return r; }
00072 inline void csTypedObjectIterator::Reset()
00073 { iter->Reset (); FetchObject (); }
00074 inline iObject *csTypedObjectIterator::GetObject () const
00075 { return iter->GetObject (); }
00076 inline iObject *csTypedObjectIterator::GetParentObj() const
00077 { return iter->GetParentObj (); }
00078 inline bool csTypedObjectIterator::IsFinished () const
00079 { return iter->IsFinished (); }
00080 inline bool csTypedObjectIterator::FindName (const char* name)
00081 { bool r = iter->FindName (name); FetchObject (); return r; }
00082
00083 #endif // __OBJITER_H__