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_MODELITERATOR_HPP 00026 #define OMF_MODELITERATOR_HPP 00027 00028 // std includes 00029 #include <queue> 00030 00031 namespace OMF 00032 { 00033 // forward declarations 00034 class Model; 00035 class ModelObject; 00036 00046 class ModelIterator 00047 { 00048 public: 00053 enum Traversal { 00054 Prefix, 00055 Postfix 00056 }; 00057 00058 ModelIterator(); 00059 ModelIterator(const ModelIterator &iter); 00060 ModelIterator(ModelObject *obj); 00061 ModelIterator(Model *model); 00062 ~ModelIterator(); 00063 00065 const ModelIterator &operator =(ModelObject *begin); 00066 const ModelIterator &operator =(Model *begin); 00067 00069 const ModelIterator &operator ++(); 00070 ModelIterator operator ++(int); 00071 00073 operator bool() const 00074 { return !_queue.empty(); } 00075 00077 ModelObject *operator *() 00078 { return _queue.front(); } 00079 00081 ModelObject *operator ->() 00082 { return _queue.front(); } 00083 00085 void pre(ModelObject *obj); 00086 void pre(Model *model); 00087 00089 void post(ModelObject *obj); 00090 void post(Model *model); 00091 00092 private: 00098 void init(ModelObject *obj, Traversal trav); 00099 00100 private: 00101 std::queue<ModelObject *> _queue; 00102 }; 00103 } 00104 00105 #endif 00106