![]() |
Public API Reference |
00001 /* 00002 Copyright (C) 2001 by Martin Geisse <mgeisse@gmx.net> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public 00015 License along with this library; if not, write to the Free 00016 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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, int &ver) const \ 00038 { id = INTERFACE##_scfGetID (); ver = INTERFACE##_VERSION; } \ 00039 public: \ 00040 inline NAME (iObject *Parent) : csTypedObjectIterator (Parent) \ 00041 { FetchObject (); } \ 00042 inline INTERFACE *Get () \ 00043 { return (INTERFACE*)(iBase*)CurrentTypedObject; } \ 00044 }; 00045 00049 class csTypedObjectIterator 00050 { 00051 protected: 00052 csRef<iObjectIterator> iter; 00053 csRef<iBase> CurrentTypedObject; 00054 00055 void FetchObject (); 00056 virtual void GetRequestedInterface (scfInterfaceID &id, int &ver) const = 0; 00057 00058 public: 00060 csTypedObjectIterator (iObject *Parent); 00062 virtual ~csTypedObjectIterator (); 00063 00065 inline bool Next(); 00067 inline void Reset(); 00069 inline iObject *GetObject () const; 00071 inline iObject *GetParentObj() const; 00073 inline bool IsFinished () const; 00075 inline bool FindName (const char* name); 00076 }; 00077 00078 inline bool csTypedObjectIterator::Next() 00079 { bool r = iter->Next (); FetchObject (); return r; } 00080 inline void csTypedObjectIterator::Reset() 00081 { iter->Reset (); FetchObject (); } 00082 inline iObject *csTypedObjectIterator::GetObject () const 00083 { return iter->GetObject (); } 00084 inline iObject *csTypedObjectIterator::GetParentObj() const 00085 { return iter->GetParentObj (); } 00086 inline bool csTypedObjectIterator::IsFinished () const 00087 { return iter->IsFinished (); } 00088 inline bool csTypedObjectIterator::FindName (const char* name) 00089 { bool r = iter->FindName (name); FetchObject (); return r; } 00090 00091 #endif // __CS_OBJITER_H__