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

OgreIteratorWrappers.h

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004     (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright © 2000-2002 The OGRE Team
00008 Also see acknowledgements in Readme.html
00009 
00010 This program is free software; you can redistribute it and/or modify it under
00011 the terms of the GNU Lesser General Public License as published by the Free Software
00012 Foundation; either version 2 of the License, or (at your option) any later
00013 version.
00014 
00015 This program is distributed in the hope that it will be useful, but WITHOUT
00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public License along with
00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00022 http://www.gnu.org/copyleft/lesser.txt.
00023 -----------------------------------------------------------------------------
00024 */
00025 #ifndef __IteratorWrappers_H__
00026 #define __IteratorWrappers_H__
00027 
00028 #include "OgrePrerequisites.h"
00029 
00030 namespace Ogre {
00031 
00046     template <class T>
00047     class VectorIterator
00048     {
00049     private:
00050         typename T::iterator mCurrent;
00051         typename T::iterator mEnd;
00053         VectorIterator() {};
00054     public:
00059         VectorIterator(typename T::iterator start, typename T::iterator end)
00060             : mCurrent(start), mEnd(end)
00061         {
00062         }
00063 
00065         bool hasMoreElements(void) const
00066         {
00067             return mCurrent != mEnd;
00068         }
00069 
00071         typename T::value_type getNext(void)
00072         {
00073             return *mCurrent++;
00074         }
00076         typename T::value_type peekNext(void)
00077         {
00078             return *mCurrent;
00079         }
00081         typename T::pointer peekNextPtr(void)
00082         {
00083             return &(*mCurrent);
00084         }
00086         void moveNext(void)
00087         {
00088             mCurrent++;
00089         }
00090 
00091 
00092 
00093     };
00094 
00109     template <class T>
00110     class MapIterator
00111     {
00112     private:
00113         typename T::iterator mCurrent;
00114         typename T::iterator mEnd;
00116         MapIterator() {};
00117     public:
00122         MapIterator(typename T::iterator start, typename T::iterator end)
00123             : mCurrent(start), mEnd(end)
00124         {
00125         }
00126 
00128         bool hasMoreElements(void) const
00129         {
00130             return mCurrent != mEnd;
00131         }
00132 
00134         typename T::mapped_type getNext(void)
00135         {
00136             return (mCurrent++)->second;
00137         }
00139         typename T::mapped_type peekNextValue(void)
00140         {
00141             return mCurrent->second;
00142         }
00144         typename T::key_type peekNextKey(void)
00145         {
00146             return mCurrent->first;
00147         }
00149         MapIterator<T> & operator=( MapIterator<T> &rhs )
00150         {
00151             mCurrent = rhs.mCurrent;
00152             mEnd = rhs.mEnd;
00153             return *this;
00154         }
00157         typename T::pointer peekNextValuePtr(void)
00158         {
00159             return &(mCurrent->second);
00160         }
00162         void moveNext(void)
00163         {
00164             mCurrent++;
00165         }
00166 
00167 
00168 
00169     };
00184     template <class T>
00185     class ConstVectorIterator
00186     {
00187     private:
00188         typename T::const_iterator mCurrent;
00189         typename T::const_iterator mEnd;
00191         ConstVectorIterator() {};
00192     public:
00197         ConstVectorIterator(typename T::const_iterator start, typename T::const_iterator end)
00198             : mCurrent(start), mEnd(end)
00199         {
00200         }
00201 
00203         bool hasMoreElements(void) const
00204         {
00205             return mCurrent != mEnd;
00206         }
00207 
00209         typename T::value_type getNext(void)
00210         {
00211             return *mCurrent++;
00212         }
00214         typename T::value_type peekNext(void) const
00215         {
00216             return *mCurrent;
00217         }
00219         typename T::const_pointer peekNextPtr(void) const
00220         {
00221             return &(*mCurrent);
00222         }
00224         void moveNext(void)
00225         {
00226             mCurrent++;
00227         }
00228 
00229 
00230 
00231     };
00232 
00247     template <class T>
00248     class ConstMapIterator
00249     {
00250     private:
00251         typename T::const_iterator mCurrent;
00252         typename T::const_iterator mEnd;
00254         ConstMapIterator() {};
00255     public:
00260         ConstMapIterator(typename T::const_iterator start, typename T::const_iterator end)
00261             : mCurrent(start), mEnd(end)
00262         {
00263         }
00264 
00266         bool hasMoreElements(void) const
00267         {
00268             return mCurrent != mEnd;
00269         }
00270 
00272         typename T::mapped_type getNext(void)
00273         {
00274             return (mCurrent++)->second;
00275         }
00277         typename T::mapped_type peekNextValue(void) const
00278         {
00279             return mCurrent->second;
00280         }
00282         typename T::key_type peekNextKey(void) const
00283         {
00284             return mCurrent->first;
00285         }
00287         MapIterator<T> & operator=( MapIterator<T> &rhs )
00288         {
00289             mCurrent = rhs.mCurrent;
00290             mEnd = rhs.mEnd;
00291             return *this;
00292         }
00295         typename T::const_pointer peekNextValuePtr(void) const
00296         {
00297             return &(mCurrent->second);
00298         }
00300         void moveNext(void)
00301         {
00302             mCurrent++;
00303         }
00304 
00305 
00306 
00307     };
00308 }
00309 #endif

Copyright © 2002-2003 by The OGRE Team
Last modified Fri May 14 23:22:18 2004