| VRS - The Virtual Rendering System |
| version 3.3 |
00001 /********************************************************************** 00002 VRS - The Virtual Rendering System 00003 Copyright (C) 2001 Computer Graphics Systems Group at the 00004 Hasso-Plattner-Institute, Potsdam, Germany. 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 This library is distributed in the hope that it will be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 See the GNU Lesser General Public License for more details. 00013 You should have received a copy of the GNU Lesser+ General Public 00014 License along with this library; if not, write to the FreeSoftware 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA, 02111-1307, USA. 00016 **********************************************************************/ 00017 00018 00019 #ifndef VRS_CONTAINER_REVERSEITERATOR_H 00020 #define VRS_CONTAINER_REVERSEITERATOR_H 00021 00022 #include <vrs/container/iterator.h> 00023 00024 namespace VRS { 00025 00027 00029 template<typename T> 00030 class ReverseIterator : public Iterator<T> { 00031 public: 00032 ReverseIterator(const Iterator<T>* sourceItr) 00033 : itr_(sourceItr) { VRS_CheckArg(sourceItr, "no iterator"); } 00034 00035 virtual unsigned int size() const { return itr_->size(); } 00036 00037 virtual T get(unsigned int index) const { 00038 VRS_CheckArg(index < itr_->size(), "index out of range"); 00039 return itr_->get(itr_->size() - 1 - index); 00040 } 00041 00042 virtual const TransactionNo& lastTransactionNo() const { return itr_->lastTransactionNo(); } 00043 00044 VRS_TYPEINFO(ReverseIterator, Iterator<T>); 00045 VRS_SERIALIZABLE(ReverseIterator); 00046 00047 protected: 00048 ReverseIterator() { } // only for serialization 00049 00050 private: 00051 SO<const Iterator<T> > itr_; 00052 }; 00053 00054 template<typename T> 00055 inline void ReverseIterator<T>::serialize(SerializationManager& doc) { 00056 VRS_SERIALIZATION_PARENT_CLASS(doc, Iterator<T>); 00057 serialization(doc, "Iterator", itr_); 00058 } 00059 00060 VRS_SERIALIZATION_REGISTRATION_TEMPLATE(ReverseIterator); 00061 00062 } // namespace VRS 00063 00064 #endif // VRS_CONTAINER_REVERSEITERATOR_H 00065