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::const_iterator mEnd; 00053 VectorIterator() {}; 00054 public: 00059 VectorIterator(typename T::iterator start, typename T::const_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::const_iterator mEnd; 00116 MapIterator() {}; 00117 public: 00122 MapIterator(typename T::iterator start, typename T::const_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 }; 00170 00171 } 00172 #endif
Copyright © 2002-2003 by The OGRE Team
Last modified Wed Jan 21 00:10:14 2004