00001 /* 00002 * Copyright (C) 2004 Andrew Sutton 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2.1 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with this library; if not, write to: 00016 * 00017 * The Free Software Foundation, Inc. 00018 * 59 Temple Place, Suite 330 00019 * Boston, MA 02111-1307 USA 00020 * 00021 * Contact: 00022 * Andrew Sutton asutton@cs.kent.edu 00023 */ 00024 00025 #ifndef OMF_CONSTITERATOR_HPP 00026 #define OMF_CONSTITERATOR_HPP 00027 00028 // std includes 00029 #include <list> 00030 #include <set> 00031 00032 namespace OMF 00033 { 00034 // forward declarations 00035 class Object; 00036 class List; 00037 class Set; 00038 00050 class ConstIterator 00051 { 00052 friend class List; 00053 friend class Set; 00054 00055 typedef std::list<OMF::Object *>::const_iterator ListIterator; 00056 typedef std::set<OMF::Object *>::const_iterator SetIterator; 00057 00062 enum Mode { 00063 None, 00064 List, 00065 Set 00066 }; 00067 00068 public: 00069 ConstIterator(); 00070 ConstIterator(const ConstIterator &i); 00071 ConstIterator(const ListIterator &i); 00072 ConstIterator(const SetIterator &i); 00073 00074 const ConstIterator &operator =(const ConstIterator &i); 00075 const ConstIterator &operator =(const ListIterator &i); 00076 const ConstIterator &operator =(const SetIterator &i); 00077 00078 Object *operator *(); 00079 Object *operator ->(); 00080 00081 ConstIterator &operator ++(); 00082 ConstIterator operator ++(int); 00083 ConstIterator &operator --(); 00084 ConstIterator operator --(int); 00085 00086 bool operator ==(const ConstIterator &i); 00087 bool operator !=(const ConstIterator &i); 00088 00089 private: 00090 Mode _mode; 00091 ListIterator _iList; 00092 SetIterator _iSet; 00093 }; 00094 } 00095 00096 #endif