PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: QueueIterator.h * 00003 * 00004 * Copyright (C) 2002-2012 The PixelLight Team (http://www.pixellight.org/) 00005 * 00006 * This file is part of PixelLight. 00007 * 00008 * PixelLight is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License as published by 00010 * the Free Software Foundation, either version 3 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * PixelLight is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public License 00019 * along with PixelLight. If not, see <http://www.gnu.org/licenses/>. 00020 \*********************************************************/ 00021 00022 00023 #ifndef __PLCORE_CONTAINER_QUEUEITERATOR_H__ 00024 #define __PLCORE_CONTAINER_QUEUEITERATOR_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include "PLCore/Container/IteratorImpl.h" 00032 00033 00034 //[-------------------------------------------------------] 00035 //[ Namespace ] 00036 //[-------------------------------------------------------] 00037 namespace PLCore { 00038 00039 00040 //[-------------------------------------------------------] 00041 //[ Forward declarations ] 00042 //[-------------------------------------------------------] 00043 template <class ValueType> class Queue; 00044 00045 00046 //[-------------------------------------------------------] 00047 //[ Classes ] 00048 //[-------------------------------------------------------] 00049 /** 00050 * @brief 00051 * Queue iterator class 00052 */ 00053 template <class ValueType> 00054 class QueueIterator : public IteratorImpl<ValueType> { 00055 00056 00057 //[-------------------------------------------------------] 00058 //[ Friends ] 00059 //[-------------------------------------------------------] 00060 friend class Queue<ValueType>; 00061 00062 00063 //[-------------------------------------------------------] 00064 //[ Private functions ] 00065 //[-------------------------------------------------------] 00066 private: 00067 /** 00068 * @brief 00069 * Constructor 00070 * 00071 * @param[in] lstQueue 00072 * Queue to operate on 00073 * @param[in] nIndex 00074 * Start index, if >= GetNumOfElements() the index is set to the last valid index 00075 */ 00076 QueueIterator(const Queue<ValueType> &lstQueue, uint32 nIndex); 00077 00078 /** 00079 * @brief 00080 * Constructor 00081 * 00082 * @param[in] lstQueue 00083 * Queue to operate on 00084 * 00085 * @note 00086 * - The iterator will start at the last element 00087 */ 00088 QueueIterator(const Queue<ValueType> &lstQueue); 00089 00090 /** 00091 * @brief 00092 * Copy constructor 00093 * 00094 * @param[in] cSource 00095 * Source to copy from 00096 */ 00097 QueueIterator(const QueueIterator<ValueType> &cSource); 00098 00099 /** 00100 * @brief 00101 * Destructor 00102 */ 00103 virtual ~QueueIterator(); 00104 00105 00106 //[-------------------------------------------------------] 00107 //[ Private data ] 00108 //[-------------------------------------------------------] 00109 private: 00110 const Queue<ValueType> *m_plstQueue; /**< Queue to operate on (always valid!) */ 00111 typename Queue<ValueType>::QueueElement *m_pNextElement; /**< Next list element, can be a null pointer */ 00112 typename Queue<ValueType>::QueueElement *m_pPreviousElement; /**< Previous list element, can be a null pointer */ 00113 00114 00115 //[-------------------------------------------------------] 00116 //[ Private virtual IteratorImpl functions ] 00117 //[-------------------------------------------------------] 00118 private: 00119 virtual IteratorImpl<ValueType> *Clone() const override; 00120 virtual bool HasNext() const override; 00121 virtual ValueType &Next() override; 00122 virtual bool HasPrevious() const override; 00123 virtual ValueType &Previous() override; 00124 00125 00126 }; 00127 00128 00129 //[-------------------------------------------------------] 00130 //[ Namespace ] 00131 //[-------------------------------------------------------] 00132 } // PLCore 00133 00134 00135 //[-------------------------------------------------------] 00136 //[ Implementation ] 00137 //[-------------------------------------------------------] 00138 #include "PLCore/Container/QueueIterator.inl" 00139 00140 00141 #endif // __PLCORE_CONTAINER_QUEUEITERATOR_H__
|