00001 #ifdef CH_LANG_CC 00002 /* 00003 * _______ __ 00004 * / ___/ / ___ __ _ / / ___ 00005 * / /__/ _ \/ _ \/ V \/ _ \/ _ \ 00006 * \___/_//_/\___/_/_/_/_.__/\___/ 00007 * Please refer to Copyright.txt, in Chombo's root directory. 00008 */ 00009 #endif 00010 00011 #ifndef _LAYOUTITERATOR_H_ 00012 #define _LAYOUTITERATOR_H_ 00013 00014 00015 00016 #include "DataIndex.H" 00017 #include "BoxLayout.H" 00018 00019 00020 #include "NamespaceHeader.H" 00021 00023 00038 class LayoutIterator 00039 { 00040 public: 00042 LayoutIterator() 00043 {} 00044 00045 // Default copy and null constructor should be fine. 00046 // Not useful to someone using the iterator. Used by 00047 // other classes in Chombo. Could make it private and 00048 // let BoxLayout have access.... 00049 00050 virtual ~LayoutIterator() 00051 {} 00052 00054 const LayoutIndex& operator () () const; 00055 00057 LayoutIndex i() const 00058 { 00059 return this->operator()(); 00060 } 00061 00063 virtual void operator ++ (); 00064 00066 void incr() 00067 { 00068 ++(*this); 00069 } 00070 00072 virtual bool ok() const; 00073 00075 void begin(); 00076 00078 void reset(); 00079 00081 00082 void end(); 00083 00084 00085 protected: 00086 friend class BoxLayout; 00087 friend class TimedDataIterator; 00088 LayoutIterator(const BoxLayout& a_boxlayout, 00089 const int* a_layoutID); 00090 00091 BoxLayout m_layout; 00092 unsigned int m_index; 00093 00094 LayoutIndex m_current; 00095 }; 00096 00097 00098 inline const LayoutIndex& LayoutIterator::operator () () const 00099 { 00100 CH_assert(ok()); 00101 return m_current; 00102 } 00103 00104 inline void LayoutIterator::operator ++ () 00105 { 00106 ++m_index; 00107 00108 if (ok()) 00109 { 00110 m_current.m_index = (*(m_layout.m_boxes))[m_index].index; 00111 } 00112 } 00113 00114 inline bool LayoutIterator::ok() const 00115 { 00116 return m_index < m_layout.size(); 00117 } 00118 00119 inline void LayoutIterator::begin() 00120 { 00121 m_index = 0; 00122 00123 if (ok()) 00124 { 00125 m_current.m_index = (*(m_layout.m_boxes))[m_index].index; 00126 } 00127 } 00128 00129 00130 #include "NamespaceFooter.H" 00131 #endif