00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00023 #ifndef __CS_OBJITER_H__
00024 #define __CS_OBJITER_H__
00025
00026 #include "iutil/object.h"
00027
00033 #define CS_DECLARE_OBJECT_ITERATOR(NAME,INTERFACE) \
00034 class NAME : public csTypedObjectIterator \
00035 { \
00036 protected: \
00037 virtual void GetRequestedInterface (scfInterfaceID &id, \
00038 int &ver) const \
00039 { id = INTERFACE##_scfGetID (); ver = INTERFACE##_VERSION; } \
00040 public: \
00041 inline NAME (iObject *Parent) : csTypedObjectIterator (Parent) \
00042 { } \
00043 inline INTERFACE *Next () \
00044 { return (INTERFACE*)(iBase*)csTypedObjectIterator::Next (); } \
00045 };
00046
00050 class csTypedObjectIterator
00051 {
00052 protected:
00053 csRef<iObjectIterator> iter;
00054 csRef<iBase> CurrentTypedObject;
00055 bool fetched;
00056
00057 void FetchObject ();
00058 iBase* GetCurrentObject();
00059 virtual void GetRequestedInterface (scfInterfaceID &id, int &ver) const = 0;
00060
00061 public:
00063 csTypedObjectIterator (iObject *Parent);
00065 virtual ~csTypedObjectIterator ();
00066
00068 iBase* Next()
00069 {
00070 iBase* cur = GetCurrentObject();
00071 FetchObject ();
00072 return cur;
00073 }
00075 void Reset () { iter->Reset (); fetched = false; }
00077 iObject *GetParentObj() const { return iter->GetParentObj (); }
00079 bool HasNext () const
00080 { return const_cast<csTypedObjectIterator*>(this)->GetCurrentObject() != 0; }
00082 iBase* FindName (const char* name);
00083 };
00084
00085 #endif // __CS_OBJITER_H__