Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

LayoutIterator.H

Go to the documentation of this file.
00001 /* _______              __
00002   / ___/ /  ___  __ _  / /  ___
00003  / /__/ _ \/ _ \/  ' \/ _ \/ _ \
00004  \___/_//_/\___/_/_/_/_.__/\___/ 
00005 */
00006 //
00007 // This software is copyright (C) by the Lawrence Berkeley
00008 // National Laboratory.  Permission is granted to reproduce
00009 // this software for non-commercial purposes provided that
00010 // this notice is left intact.
00011 // 
00012 // It is acknowledged that the U.S. Government has rights to
00013 // this software under Contract DE-AC03-765F00098 between
00014 // the U.S.  Department of Energy and the University of
00015 // California.
00016 //
00017 // This software is provided as a professional and academic
00018 // contribution for joint exchange. Thus it is experimental,
00019 // is provided ``as is'', with no warranties of any kind
00020 // whatsoever, no support, no promise of updates, or printed
00021 // documentation. By using this software, you acknowledge
00022 // that the Lawrence Berkeley National Laboratory and
00023 // Regents of the University of California shall have no
00024 // liability with respect to the infringement of other
00025 // copyrights by any part of this software.
00026 //
00027 #ifndef LAYOUTITERATOR_H
00028 #define LAYOUTITERATOR_H
00029 
00030 #ifndef WRAPPER
00031 
00032 #include "DataIndex.H"
00033 #include "BoxLayout.H"
00034 
00035 #endif
00036 
00038 
00052 class LayoutIterator
00053 {
00054 public:
00055   // default copy and null constructor should be fine
00056   // not useful to someone using the iterator.  Used by
00057   // other classes in Chombo.  Could make it private and
00058   // let BoxLayout have access....
00059   ~LayoutIterator() {;}
00061   const LayoutIndex& operator()() const;
00062   LayoutIndex i() const { return this ->operator()();}
00063 
00065   void operator++();
00066   void incr(){ ++(*this);}
00067 
00069   bool ok() const;
00070 
00072   void reset();
00073 
00075   void begin();
00076 
00078 
00081   void end();
00082 
00083 
00084 
00085 private:
00086 
00087   friend class BoxLayout;
00088 
00089   LayoutIterator(const BoxLayout& boxlayout, const int* layoutID);
00090 
00091   //int m_begin, m_end;
00092 
00093   const BoxLayout m_layout;
00094 
00095   unsigned int m_index;
00096 
00097   LayoutIndex m_current;
00098 
00099 };
00100 
00101 
00102 #ifndef WRAPPER
00103 
00104 inline const LayoutIndex& LayoutIterator::operator()() const
00105 {
00106   assert(ok());
00107   return m_current;
00108 }
00109 
00110 inline void LayoutIterator::operator++()
00111 {
00112   ++m_index;
00113   if(ok())
00114     m_current.m_index = (*(m_layout.m_boxes))[m_index].index;
00115 }
00116 
00117 inline bool LayoutIterator::ok() const
00118 {
00119   return m_index < m_layout.size();
00120 }
00121 
00122 
00123 inline void LayoutIterator::begin()
00124 {
00125   m_index = 0;
00126   if(ok())
00127     m_current.m_index = (*(m_layout.m_boxes))[m_index].index;
00128 }
00129 #endif /*WRAPPER*/
00130 
00131 #endif 

Generated on Wed Apr 16 14:26:49 2003 for Chombo by doxygen1.2.16