OGRE  1.9
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreIteratorRange.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2014 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __Ogre_Iterator_Range_H__
29 #define __Ogre_Iterator_Range_H__
30 
31 #include "OgreHeaderPrefix.h"
32 
33 #if OGRE_USE_BOOST
34 # if OGRE_COMPILER == OGRE_COMPILER_CLANG || OGRE_COMPILER == OGRE_COMPILER_GNUC
35 # pragma GCC diagnostic push
36 #if OGRE_COMPILER == OGRE_COMPILER_GNUC
37 # pragma GCC diagnostic ignored "-Wpragmas"
38 #elif OGRE_COMPILER == OGRE_COMPILER_CLANG
39 # pragma GCC diagnostic ignored "-Wdocumentation"
40 #endif
41 # pragma GCC diagnostic ignored "-Wshadow"
42 # pragma GCC diagnostic ignored "-Wpadded"
43 # pragma GCC diagnostic ignored "-Wweak-vtables"
44 # pragma GCC diagnostic ignored "-Wall"
45 # pragma GCC diagnostic ignored "-Wundef"
46 # endif
47 
48 # include <boost/range.hpp>
49 
50 # if OGRE_COMPILER == OGRE_COMPILER_CLANG || OGRE_COMPILER == OGRE_COMPILER_GNUC
51 # pragma GCC diagnostic pop
52 # endif
53 #endif
54 
55 namespace Ogre {
56 
68 template <typename T>
70 
71 #if !OGRE_USE_BOOST
72 
74 
75  public :
76 
81  iterator_range( T b , T e ) : mBegin(b) , mEnd(e){}
82 
84  T begin() const { return mBegin; }
85 
87  T end() const { return mEnd; }
88 
90  bool empty() const { return mBegin = mEnd ; }
91 
93  bool equal( const iterator_range& other ) const
94  {return mBegin == other.mBegin && mEnd == other.mEnd;}
95 
97  bool operator==( const iterator_range& rhs ) const
98  {return equal( rhs ) ;}
99 
101  bool operator!=( const iterator_range& rhs ) const { return !operator==(rhs); }
102 
109  typedef T iterator;
110 
117  typedef T const_iterator;
118 
120 
125 #else
126  public: typedef boost::iterator_range<T> type ;
128 
129 #endif
130 };
131 
132 
141 template<typename T>
142 struct VectorRange : public iterator_range<typename T::iterator>::type
143 {
144 
149  VectorRange( T& c )
150  : iterator_range<typename T::iterator>::type( c.begin(), c.end() )
151  {}
152 
157  VectorRange( typename T::iterator b, typename T::iterator e )
158  : iterator_range<typename T::iterator>::type( b, e )
159  {}
160 
162  bool operator==( const VectorRange& rhs ) const { return equal( rhs) ; }
164  bool operator!=( const VectorRange& rhs ) const { return !equal( rhs) ; }
165 
166 
167 #ifdef __Ogre_Iterator_Wrapper_H__
168  operator VectorIterator<T>(){return VectorIterator<T>( this->begin(), this->end());}
171  operator ConstVectorIterator<T>(){return ConstVectorIterator<T>( this->begin(), this->end());}
172 #endif
173 
174 };
175 
184 template<typename T>
185 struct ConstVectorRange : public iterator_range<typename T::const_iterator>::type
186 {
187 
192  ConstVectorRange( const T& c )
193  : iterator_range<typename T::const_iterator>::type( c.begin(), c.end() )
194  {}
195 
200  ConstVectorRange( typename T::iterator b, typename T::iterator e )
201  : iterator_range<typename T::const_iterator>::type( b, e )
202  {}
203 
208  ConstVectorRange( typename T::const_iterator b, typename T::const_iterator e )
209  : iterator_range<typename T::const_iterator>::type( b, e )
210  {}
211 
217  : iterator_range<typename T::const_iterator>::type( rhs.begin(), rhs.end() )
218  {}
219 
221  bool operator==( const ConstVectorRange& rhs ) const { return equal( rhs) ; }
223  bool operator!=( const ConstVectorRange& rhs ) const { return !equal( rhs) ; }
224 
225 
226 
227 
228 #ifdef __Ogre_Iterator_Wrapper_H__
229  operator ConstVectorIterator<T>(){return ConstVectorIterator<T>( this->begin(),this->end());}
231 #endif
232 
233 };
234 
235 
236 
245 template<typename T>
246 struct MapRange : public iterator_range<typename T::iterator>::type
247 {
252  MapRange( T& c )
253  : iterator_range<typename T::iterator>::type( c.begin(), c.end() )
254  {}
255 
260  MapRange( typename T::iterator b, typename T::iterator e )
261  : iterator_range<typename T::iterator>::type( b, e )
262  {}
263 
265  bool operator==( const MapRange& rhs ) const { return equal( rhs) ; }
267  bool operator!=( const MapRange& rhs ) const { return !equal( rhs) ; }
268 
269 
270 #ifdef __Ogre_Iterator_Wrapper_H__
271  operator MapIterator<T>(){return MapIterator<T>( this->begin(), this->end());}
274  operator ConstMapIterator<T>(){return ConstMapIterator<T>( this->begin(), this->end());}
275 #endif
276 
277 };
278 
287 template<typename T>
288 struct ConstMapRange : public iterator_range<typename T::const_iterator>::type
289 {
290 
295  ConstMapRange( const T& c )
296  : iterator_range<typename T::const_iterator>::type( c.begin(), c.end() )
297  {}
298 
303  ConstMapRange( typename T::iterator b, typename T::iterator e )
304  : iterator_range<typename T::const_iterator>::type( b, e )
305  {}
306 
311  ConstMapRange( typename T::const_iterator b, typename T::const_iterator e )
312  : iterator_range<typename T::const_iterator>::type( b, e )
313  {}
314 
320  : iterator_range<typename T::const_iterator>::type( rhs.begin(), rhs.end() )
321  {}
322 
324  bool operator==( const ConstMapRange& rhs ) const { return equal( rhs) ; }
326  bool operator!=( const ConstMapRange& rhs ) const { return !equal( rhs) ; }
327 
328 
329 #ifdef __Ogre_Iterator_Wrapper_H__
330  operator ConstMapIterator<T>(){return ConstMapIterator<T>( this->begin(),this->end());}
332 #endif
333 
334 };
335 
336 #include "OgreHeaderSuffix.h"
337 
338 }
339 #endif
bool operator!=(const ConstMapRange &rhs) const
comparison operator for inequality
VectorRange(T &c)
Constructor.
ConstVectorRange(const T &c)
Constructor.
T const_iterator
typedef to fulfill container interface
ConstMapRange(typename T::iterator b, typename T::iterator e)
Constructor.
Predefined type.
bool operator==(const MapRange &rhs) const
comparison operator for equality
bool operator!=(const MapRange &rhs) const
comparison operator for inequality
bool operator==(const ConstMapRange &rhs) const
comparison operator for equality
T iterator
typedef to fulfill container interface
iterator_range< T > type
defines the real used type
Predefined type.
Base for an iterator_range.
bool operator!=(const VectorRange &rhs) const
comparison operator for inequality
T begin() const
access to the begin of the range
ConstVectorRange(const VectorRange< T > &rhs)
Constructor.
Concrete IteratorWrapper for nonconst access to the underlying key-value container.
ConstVectorRange(typename T::const_iterator b, typename T::const_iterator e)
Constructor.
ConstVectorRange(typename T::iterator b, typename T::iterator e)
Constructor.
iterator_range(T b, T e)
Constructor.
ConstMapRange(const MapRange< T > &rhs)
Constructor.
bool operator==(const VectorRange &rhs) const
comparison operator for equality
bool operator!=(const ConstVectorRange &rhs) const
comparison operator for inequality
bool operator!=(const iterator_range &rhs) const
comparison operator for inequality
Concrete IteratorWrapper for const access to the underlying container.
ConstMapRange(const T &c)
Constructor.
VectorRange(typename T::iterator b, typename T::iterator e)
Constructor.
bool operator==(const ConstVectorRange &rhs) const
comparison operator for equality
Predefined type.
bool empty() const
informs if there are any elements in the range
ConstMapRange(typename T::const_iterator b, typename T::const_iterator e)
Constructor.
Concrete IteratorWrapper for const access to the underlying key-value container.
MapRange(typename T::iterator b, typename T::iterator e)
Constructor.
MapRange(T &c)
Constructor.
bool operator==(const iterator_range &rhs) const
comparison operator for equality
bool equal(const iterator_range &other) const
comparison for equality
Concrete IteratorWrapper for nonconst access to the underlying container.
T end() const
access to the end of the range