CrystalSpace

Public API Reference

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

csutil/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 "csextern.h"
00027 #include "iutil/object.h"
00028 
00034 #define CS_DECLARE_OBJECT_ITERATOR(NAME,INTERFACE)                      \
00035   class NAME : public csTypedObjectIterator                             \
00036   {                                                                     \
00037   protected:                                                            \
00038     virtual void GetRequestedInterface (scfInterfaceID &id,             \
00039       int &ver) const                                                   \
00040     { id = scfInterface<INTERFACE>::GetID();                            \
00041       ver = scfInterface<INTERFACE>::GetVersion(); }                    \
00042   public:                                                               \
00043     inline NAME (iObject *Parent) : csTypedObjectIterator (Parent)      \
00044       { }                                                               \
00045     inline INTERFACE *Next ()                                           \
00046       { return (INTERFACE*)(iBase*)csTypedObjectIterator::Next (); }    \
00047   };
00048 
00052 class CS_CSUTIL_EXPORT csTypedObjectIterator
00053 {
00054 protected:
00055   csRef<iObjectIterator> iter;
00056   csRef<iBase> CurrentTypedObject;
00057   bool fetched;
00058 
00059   void FetchObject ();
00060   iBase* GetCurrentObject();
00061   virtual void GetRequestedInterface (scfInterfaceID &id, int &ver) const = 0;
00062 
00063 public:
00065   csTypedObjectIterator (iObject *Parent);
00067   virtual ~csTypedObjectIterator ();
00068 
00070   iBase* Next()
00071   {
00072     iBase* cur = GetCurrentObject();
00073     FetchObject ();
00074     return cur;
00075   }
00077   void Reset () { iter->Reset (); fetched = false; }
00079   iObject *GetParentObj() const { return iter->GetParentObj (); }
00081   bool HasNext () const
00082   { return const_cast<csTypedObjectIterator*>(this)->GetCurrentObject() != 0; }
00084   iBase* FindName (const char* name);
00085 };
00086 
00087 #endif // __CS_OBJITER_H__

Generated for Crystal Space by doxygen 1.2.18