CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

objiter.h

Go to the documentation of this file.
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,             \
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__

Generated for Crystal Space by doxygen 1.2.14