| VRS - The Virtual Rendering System |
| version 3.3 |
00001 /****************************************************************************** 00002 * VRS - The Virtual Rendering System 00003 * Copyright (C) 2000-2004 Computer Graphics Systems Group at the 00004 * Hasso-Plattner-Institute (HPI), Potsdam, Germany. 00005 * 00006 * This library is free software; you can redistribute it and/or modify it 00007 * under the terms of the GNU Lesser General Public License as published by 00008 * the Free Software Foundation; either version 2.1 of the License, or (at 00009 * your option) any later version. This library is distributed in the hope 00010 * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied 00011 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU Lesser General Public License for more details. You should have received 00013 * a copy of the GNU Lesser+ General Public License along with this library; if 00014 * not, write to the FreeSoftware Foundation, Inc., 59 Temple Place, Suite 330, 00015 * Boston, MA, 02111-1307, USA. 00016 ******************************************************************************/ 00017 00018 // $Id: deque.h 6014 2007-08-09 07:51:16Z Konstantin_Baumann $ 00019 // $Date: 2007-08-09 09:51:16 +0200 (Thu, 09 Aug 2007) $ 00020 // $Revision: 6014 $ 00021 // $State$ 00022 // $Author: Konstantin_Baumann $ 00023 // 00024 // $Log$ 00025 // Revision 1.26 2004/03/12 16:28:39 baumann 00026 // macros VRS_NAMESPACE_BEGIN/_END expanded and removed 00027 // 00028 // Revision 1.25 2004/03/10 15:17:42 kirsch 00029 // changes due to two-stage name lookup in non-dependent templates (gcc 3.4) 00030 // 00031 // Revision 1.24 2004/02/12 08:29:07 gerber 00032 // added macro VRS_SERIALIZATION_PARENT_CLASS for parent serialization 00033 // 00034 // Revision 1.23 2004/02/10 10:50:50 wendland 00035 // added VRS_SERIALIZATION_PARENT_CLASS 00036 // 00037 // Revision 1.22 2004/01/28 11:36:05 gerber 00038 // adjusted method serialize to the new serializationmanager 00039 // 00040 // Revision 1.21 2004/01/19 11:43:57 baumann 00041 // serialization mechanism improved 00042 // 00043 // Revision 1.20 2004/01/19 07:28:03 baumann 00044 // serialization mechanism improved 00045 // 00046 // Revision 1.19 2004/01/15 14:21:45 baumann 00047 // serialization mechanism improved 00048 // 00049 // Revision 1.18 2004/01/15 14:16:54 baumann 00050 // serialization mechanism improved 00051 // 00052 // Revision 1.17 2003/11/07 14:19:24 kirsch 00053 // removed leading underscore from include guards 00054 // 00055 // Revision 1.16 2003/02/27 13:25:15 kirsch 00056 // removed unused parameter 00057 // 00058 // Revision 1.15 2002/11/06 08:16:05 baumann 00059 // moved implementation of serialize operator from namespace std to namespace VRS 00060 // 00061 // Revision 1.14 2002/11/06 07:53:50 baumann 00062 // cleanup of class registration for serialization 00063 // 00064 // Revision 1.13 2002/10/24 06:56:00 skirsch 00065 // fixed some warnings by making casts explicit 00066 // 00067 // Revision 1.12 2002/08/06 16:24:01 baumann 00068 // VRS_API removed for template classes 00069 // 00070 // Revision 1.11 2002/07/11 14:21:52 kersting 00071 // added version for serialize method 00072 // 00073 // Revision 1.10 2002/07/03 15:52:50 baumann 00074 // several changes for iterator code 00075 // most iterators are now serializable again 00076 // 00077 // Revision 1.9 2002/07/03 07:45:32 kersting 00078 // changed broken comment 00079 // 00080 // Revision 1.8 2002/07/02 15:23:48 baumann 00081 // non-persistent containers now have the prefix NonPersistent, e.g. NonPersistentArray<T> 00082 // persistent containers now have no prefix, e.g. Array<T> 00083 // 00084 // Revision 1.7 2002/07/02 06:12:34 baumann 00085 // VRS::Iterator<T> completely rewritten 00086 // 00087 // Revision 1.6 2002/06/25 10:51:55 baumann 00088 // added some method for supporting STL algorithms 00089 // to Array<T>, List<T>, Deque<T> and StaticArray<T>: 00090 // beginSTL(), endSTL(), containerSTL() 00091 // 00092 // Revision 1.5 2002/05/09 12:36:37 kirsch 00093 // added typename 00094 // 00095 // Revision 1.4 2002/04/02 08:33:06 baumann 00096 // bug fix for serialization of iterators 00097 // 00098 // Revision 1.3 2002/04/02 08:13:43 baumann 00099 // made iterator persistent 00100 // 00101 // Revision 1.2 2002/03/07 14:20:37 kosta 00102 // VRS_API added for the iterator 00103 // 00104 // Revision 1.1 2002/03/04 12:03:54 kersting 00105 // directory structure changes 00106 // 00107 // Revision 1.10 2002/03/03 21:44:24 kosta 00108 // VRS_TYPEINFO-macro rewritten 00109 // 00110 // Revision 1.9 2002/03/03 16:37:59 kosta 00111 // changed VRS-typeinfo to C++-typeid 00112 // 00113 // Revision 1.8 2002/02/25 09:56:08 kosta 00114 // debug output improved 00115 // 00116 // Revision 1.7 2002/02/24 16:39:16 kosta 00117 // VRS_CLASSNAME macros now consider namespace prefixes 00118 // 00119 // Revision 1.6 2002/02/19 10:34:07 kosta 00120 // undone all changes since 2002-02-15 00121 // 00122 // Revision 1.3 2002/02/14 09:37:20 kosta 00123 // automatic serialization registration for template classes implemented 00124 // 00125 // Revision 1.2 2002/02/13 16:28:11 kosta 00126 // implementation of the serialize()-method moved outside the class declaration 00127 // 00128 // Revision 1.1 2002/02/12 15:04:34 kosta 00129 // VRS container classes completely rewritten using STL 00130 // 00131 00132 #ifndef VRS_CONTAINER_DEQUE_H 00133 #define VRS_CONTAINER_DEQUE_H 00134 00135 #include <vrs/container/sequencecontainerstl.h> 00136 #include <deque> 00137 00138 namespace VRS { 00139 00140 template<typename T> class DequeIterator; 00141 00142 template<typename T> 00143 class NonPersistentDeque : public SequenceContainerSTL<T, std::deque<T> > { 00144 public: 00145 NonPersistentDeque() : SequenceContainerSTL<T, std::deque<T> >() { } 00146 NonPersistentDeque(unsigned int size) : SequenceContainerSTL<T, std::deque<T> >(size) { } 00147 NonPersistentDeque(unsigned int size, const T& initValue) : SequenceContainerSTL<T, std::deque<T> >(size, initValue) { } 00148 NonPersistentDeque(const Iterator<T>* sourceItr) : SequenceContainerSTL<T, std::deque<T> >(sourceItr) { } 00149 00150 virtual Iterator<T>* newIterator() const { return (this->iterator_ ? this->iterator_ : new DequeIterator<T>(this)); } 00151 00152 void reserve(unsigned int value) { this->containerSTL().reserve(value); } 00153 00154 VRS_TYPEINFO(NonPersistentDeque, VRS_TEMPLATE_ARGS_2(T, std::deque<T>, SequenceContainerSTL)); 00155 VRS_SERIALIZABLE_ABSTRACT_CLASS(NonPersistentDeque); 00156 }; 00157 00158 template<typename T> 00159 void NonPersistentDeque<T>::serialize(SerializationManager&) { 00160 VRS_NoImpl(NonPersistentDeque<T>::ClassNameVRS() << "::serialize() not supported: use " 00161 "Deque<T> for serialization instead!"); 00162 } 00163 00164 template<typename T> 00165 class Deque : public NonPersistentDeque<T> { 00166 public: 00167 Deque() : NonPersistentDeque<T>() { } 00168 Deque(unsigned int size) : NonPersistentDeque<T>(size) { } 00169 Deque(unsigned int size, const T& initValue) : NonPersistentDeque<T>(size, initValue) { } 00170 Deque(const Iterator<T>* sourceItr) : NonPersistentDeque<T>(sourceItr) { } 00171 00172 VRS_TYPEINFO(Deque, NonPersistentDeque<T>); 00173 VRS_SERIALIZABLE(Deque); 00174 }; 00175 00176 template<typename T> 00177 void Deque<T>::serialize(SerializationManager& doc) { 00178 VRS_SERIALIZATION_PARENT_CLASS(doc, SharedObj); // skip some super-classes!!! 00179 serialization(doc, "Container", this->containerSTL()); 00180 } 00181 00182 VRS_SERIALIZATION_REGISTRATION_TEMPLATE(Deque) 00183 00184 template<typename T> 00185 class DequeIterator : public SequenceContainerIteratorSTL<T, std::deque<T> > { 00186 public: 00187 DequeIterator(const NonPersistentDeque<T>* container) 00188 : SequenceContainerIteratorSTL<T, std::deque<T> >(container) { } 00189 00190 VRS_TYPEINFO(DequeIterator, VRS_TEMPLATE_ARGS_2(T, std::deque<T>, SequenceContainerIteratorSTL)); 00191 VRS_SERIALIZABLE(DequeIterator); 00192 00193 protected: 00194 DequeIterator() { } // only for serialization 00195 }; 00196 00197 template<typename T> 00198 void DequeIterator<T>::serialize(SerializationManager& doc) { 00199 // typedef, because the serialization macro doesn't like templates with 2 template parameter 00200 typedef SequenceContainerIteratorSTL<T, std::deque<T> > Parent; 00201 VRS_SERIALIZATION_PARENT_CLASS(doc, Parent); 00202 } 00203 00204 VRS_SERIALIZATION_REGISTRATION_TEMPLATE(DequeIterator); 00205 00206 template<typename T> 00207 inline void 00208 serialization( 00209 SerializationManager& manager, 00210 const std::string& attributeName, 00211 std::deque<T>& attributeValue 00212 ) { 00213 VRS_SERIALIZATION_START_CLASS(manager, attributeName, attributeValue); 00214 unsigned int size = static_cast<unsigned int>(attributeValue.size()); 00215 serialization(manager, "Size", size); 00216 attributeValue.resize(size); 00217 for(typename std::deque<T>::iterator i = attributeValue.begin(), iEnd = attributeValue.end(); i != iEnd; ++i) { 00218 T obj = *i; 00219 serialization(manager, "Value", obj); 00220 *i = obj; 00221 } 00222 VRS_SERIALIZATION_END_CLASS(manager, attributeName, attributeValue); 00223 } 00224 00225 } // namespace VRS 00226 00227 #endif // VRS_CONTAINER_DEQUE_H