summaryrefslogtreecommitdiffstats log msg author committer range
path: root/rasodmg/iterator.hh
blob: d5f459ee83e764c4d193db7e08266c82a49ccf81 (plain)
 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  /* * This file is part of rasdaman community. * * Rasdaman community is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Rasdaman community is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with rasdaman community. If not, see . * * Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann / rasdaman GmbH. * * For more information please see * or contact Peter Baumann via . / /** * INCLUDE: iterator.hh * * MODULE: rasodmg * CLASS: r_Iterator * * COMMENTS: * None */ #ifndef _D_ITERATOR_ #define _D_ITERATOR_ #include "raslib/error.hh" #ifdef __VISUALC__ template class r_Collection; #else #include "rasodmg/collection.hh" #endif //@ManMemo: Module: {\bf rasodmg} /*@Doc: The template class \Ref{r_Iterator} defines the generic behavior for iteration. All iterators use a consistent protocol for sequentially returning each element from the collection over which the iteration is defined. When an iterator is constructed, it is either initialized with another iterator or is set to null. When an iterator is constructed via the {\tt create_iterator()} method defined in \Ref{r_Collection}, the iterator is initailized to point to the first element, if there is one. */ /** * \ingroup Rasodmgs */ template class r_Iterator { public: /// default constructor r_Iterator(); /// copy constructor r_Iterator( const r_Iterator& iter ); /// constructor getting the collection on which to iterate (used for {\tt r_Collection::create_iterator()}) r_Iterator( r_Collection& source, int removed_objects=0 ); /** Creates an iterator which points to the first element of the element collection. If {\tt removed_objects} ist set to 1, the iterator points to the first element of the list containing the removed objects (for internal use). */ /// destructor ~r_Iterator(); /// assignment operator r_Iterator& operator=( const r_Iterator& iter ); /// comparisons: equal if they point to the same element in the same collection, /// not equal if they point to different collections or elements int is_equal( const r_Iterator& iter ) const; /// prefix incrementor r_Iterator& operator++(); /// postfix incrementor r_Iterator operator++( int ); /// re-initialize the iterator to the start of iteration for the same collection void reset( int removed_objects=0 ); /** Resets the iterator to point to the first element of the element collection. If {\tt removed_objects} ist set to 1, the iterator points to the first element of the list containing the removed objects (for internal use). */ /// returns 1 if there are more elements to be visited in the iteration and 0 if iteration is complete inline int not_done() const; /// advances one element void advance(); /// the dereference operator gets the actual element T operator*() throw( r_Error ); /// gets the actual element T get_element() const throw( r_Error ); /// gets the actual element, advances one element, and returns whether iteration is complete or not int next( T& element ); /// replaces the actual element (can only be used with r_List) void replace_element( const T& element ); private: /// flag for end of iteration int ndone; /// pointer to the collection on which is iterated r_Collection* collection; /// pointer to the actual element typename r_Collection::CNode* ptr; }; #include "iterator.icc" #ifdef EARLY_TEMPLATE #ifdef __EXECUTABLE__ #ifdef __VISUALC__ #include "iterator.cpp" #else #include "iterator.cc" #endif #endif #endif #endif