/usr/include/OGRE/OgreIteratorWrapper.h is in libogre-1.9-dev 1.9.0+dfsg1-7.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 | /*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __Ogre_Iterator_Wrapper_H__
#define __Ogre_Iterator_Wrapper_H__
#include "OgreHeaderPrefix.h"
namespace Ogre{
/**
*
* @brief Basefunctionality for IteratorWrappers
*
*
* @tparam T a Container like vector list map ...
* @tparam IteratorType T::iterator or T::const_iterator
* @tparam ValType T::mapped_type in case of a map, T::value_type for vector, list,...
*
* Have a look at VectorIteratorWrapper and MapIteratorWrapper for a concrete usage
*/
template <typename T, typename IteratorType, typename ValType>
class IteratorWrapper
{
private:
/// Private constructor since only the parameterised constructor should be used
IteratorWrapper();
protected:
IteratorType mBegin;
IteratorType mCurrent;
IteratorType mEnd;
public:
/// Type you expect to get by funktions like peekNext(Value)
typedef ValType ValueType;
/// Type you expect to get by funktions like peekNext(Value)Ptr
typedef ValType* PointerType;
/**
@brief Typedef to fulfill container interface
Useful if you want to use BOOST_FOREACH
@note there is no distinction between const_iterator and iterator.
\n keep this in mind if you want to derivate from this class.
*/
typedef IteratorType iterator;
/**
@brief Typedef to fulfill container interface
Useful if you want to use BOOST_FOREACH
@note there is no distinction between const_iterator and iterator.
\n keep this in mind if you want to derivate from this class.
*/
typedef IteratorType const_iterator;
/** Constructor.
@remarks
Provide a start and end iterator to initialise.
*/
IteratorWrapper ( IteratorType start, IteratorType last )
: mBegin( start ), mCurrent ( start ), mEnd ( last )
{
}
/** Returns true if there are more items in the collection. */
bool hasMoreElements ( ) const
{
return mCurrent != mEnd;
}
/** Moves the iterator on one element. */
void moveNext ( )
{
++mCurrent;
}
/** Bookmark to the begin of the underlying collection */
const IteratorType& begin() {return mBegin;}
/** Full access to the current iterator */
IteratorType& current(){return mCurrent;}
/** Bookmark to the end (one behind the last element) of the underlying collection */
const IteratorType& end() {return mEnd;}
};
/**
*
* @brief Prepared IteratorWrapper for container like std::vector
*
*
* @tparam T = Container eg vector
* @tparam IteratorType T::iterator or T::const_iterator
*
* Have a look at VectorIterator and ConstVectorIterator for a more concrete usage
*/
template <typename T, typename IteratorType>
class VectorIteratorWrapper : public IteratorWrapper<T, IteratorType, typename T::value_type>
{
public:
typedef typename IteratorWrapper<T, IteratorType, typename T::value_type>::ValueType ValueType ;
typedef typename IteratorWrapper<T, IteratorType, typename T::value_type>::PointerType PointerType ;
/**
* @brief c'tor
*
* Constructor that provide a start and end iterator to initialise.
*
* @param start Start iterator
* @param last End iterator
*/
VectorIteratorWrapper ( IteratorType start, IteratorType last )
: IteratorWrapper<T, IteratorType, typename T::value_type>( start, last )
{
}
/** Returns the next(=current) element in the collection, without advancing to the next. */
ValueType peekNext ( ) const
{
return *(this->mCurrent);
}
/** Returns a pointer to the next(=current) element in the collection, without advancing to the next afterwards. */
PointerType peekNextPtr ( ) const
{
return &(*(this->mCurrent) );
}
/** Returns the next(=current) value element in the collection, and advances to the next. */
ValueType getNext ( )
{
return *(this->mCurrent++);
}
};
/**
*
* @brief Concrete IteratorWrapper for nonconst access to the underlying container
*
* @tparam T Container
*
*/
template <typename T>
class VectorIterator : public VectorIteratorWrapper<T, typename T::iterator>{
public:
/** Constructor.
@remarks
Provide a start and end iterator to initialise.
*/
VectorIterator( typename T::iterator start, typename T::iterator last )
: VectorIteratorWrapper<T, typename T::iterator>(start , last )
{
}
/** Constructor.
@remarks
Provide a container to initialise.
*/
explicit VectorIterator( T& c )
: VectorIteratorWrapper<T, typename T::iterator> ( c.begin(), c.end() )
{
}
};
/**
*
* @brief Concrete IteratorWrapper for const access to the underlying container
*
*
* @tparam T = Container
*
*/
template <typename T>
class ConstVectorIterator : public VectorIteratorWrapper<T, typename T::const_iterator>{
public:
/** Constructor.
@remarks
Provide a start and end iterator to initialise.
*/
ConstVectorIterator( typename T::const_iterator start, typename T::const_iterator last )
: VectorIteratorWrapper<T, typename T::const_iterator> (start , last )
{
}
/** Constructor.
@remarks
Provide a container to initialise.
*/
explicit ConstVectorIterator ( const T& c )
: VectorIteratorWrapper<T, typename T::const_iterator> (c.begin() , c.end() )
{
}
};
/**
*
* @brief Prepared IteratorWrapper for key-value container
*
*
* @tparam T Container (map - or also set )
* @tparam IteratorType T::iterator or T::const_iterator
*
* Have a look at MapIterator and ConstMapIterator for a concrete usage
*/
template <typename T, typename IteratorType>
class MapIteratorWrapper : public IteratorWrapper<T, IteratorType, typename T::mapped_type>
{
public:
/// Redefined ValueType for a map/set
typedef typename IteratorWrapper<T, IteratorType, typename T::mapped_type>::ValueType ValueType ;
/// Redefined PointerType for a map/set
typedef typename IteratorWrapper<T, IteratorType, typename T::mapped_type>::PointerType PointerType ;
/// Unused, just to make it clear that map/set::value_type is not a ValueType
typedef typename T::value_type PairType ;
/// Type you expect to get by funktions like peekNextKey
typedef typename T::key_type KeyType;
/** Constructor.
@remarks
Provide a start and end iterator to initialise.
*/
MapIteratorWrapper ( IteratorType start, IteratorType last )
: IteratorWrapper<T, IteratorType, typename T::mapped_type>( start, last )
{
}
/** Returns the next(=current) key element in the collection, without advancing to the next. */
KeyType peekNextKey(void) const
{
return this->mCurrent->first;
}
/** Returns the next(=current) value element in the collection, without advancing to the next. */
ValueType peekNextValue ( ) const
{
return this->mCurrent->second;
}
/** Returns a pointer to the next/current value element in the collection, without
advancing to the next afterwards. */
const PointerType peekNextValuePtr ( ) const
{
return &(this->mCurrent->second);
}
/** Returns the next(=current) value element in the collection, and advances to the next. */
ValueType getNext()
{
return ((this->mCurrent++)->second) ;
}
};
/**
*
* @brief Concrete IteratorWrapper for nonconst access to the underlying key-value container
*
*
* @remarks Template key-value container
*
*/
template <typename T>
class MapIterator : public MapIteratorWrapper<T, typename T::iterator>{
public:
/** Constructor.
@remarks
Provide a start and end iterator to initialise.
*/
MapIterator( typename T::iterator start, typename T::iterator last )
: MapIteratorWrapper<T, typename T::iterator>(start , last )
{
}
/** Constructor.
@remarks
Provide a container to initialise.
*/
explicit MapIterator( T& c )
: MapIteratorWrapper<T, typename T::iterator> ( c.begin(), c.end() )
{
}
};
/**
*
* @brief Concrete IteratorWrapper for const access to the underlying key-value container
*
*
* @tparam T key-value container
*
*/
template <typename T>
class ConstMapIterator : public MapIteratorWrapper<T, typename T::const_iterator>{
public:
/** Constructor.
@remarks
Provide a start and end iterator to initialise.
*/
ConstMapIterator( typename T::const_iterator start, typename T::const_iterator last )
: MapIteratorWrapper<T, typename T::const_iterator> (start , last )
{
}
/** Constructor.
@remarks
Provide a container to initialise.
*/
explicit ConstMapIterator ( const T& c )
: MapIteratorWrapper<T, typename T::const_iterator> (c.begin() , c.end() )
{
}
};
}
#include "OgreHeaderSuffix.h"
#endif
|