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_ITERATOR_HPP 00026 #define OMF_ITERATOR_HPP 00027 00028 // std includes 00029 #include <list> 00030 #include <set> 00031 #include <map> 00032 00033 namespace OMF 00034 { 00035 // forward declarations 00036 class Object; 00037 class List; 00038 class Set; 00039 00051 class Iterator 00052 { 00053 friend class List; 00054 friend class Set; 00055 00056 protected: 00057 typedef std::list<Object *>::iterator ListIterator; 00058 typedef std::set<Object *>::iterator SetIterator; 00059 typedef std::map<unsigned, Object *>::iterator MapIterator; 00060 00065 enum Mode { 00066 None, 00067 List, 00068 Set, 00069 Map 00070 }; 00071 00072 public: 00073 Iterator(); 00074 Iterator(const Iterator &i); 00075 Iterator(const ListIterator &i); 00076 Iterator(const SetIterator &i); 00077 Iterator(const MapIterator &i); 00078 00079 const Iterator &operator =(const Iterator &i); 00080 const Iterator &operator =(const ListIterator &i); 00081 const Iterator &operator =(const SetIterator &i); 00082 const Iterator &operator =(const MapIterator &i); 00083 00084 Object *operator *(); 00085 Object *operator ->(); 00086 00087 Iterator &operator ++(); 00088 Iterator operator ++(int); 00089 Iterator &operator --(); 00090 Iterator operator --(int); 00091 00092 bool operator ==(const Iterator &i); 00093 bool operator !=(const Iterator &i); 00094 00095 private: 00096 Mode _mode; 00097 ListIterator _iList; 00098 SetIterator _iSet; 00099 MapIterator _iMap; 00100 }; 00101 } 00102 00103 #endif