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 
00053 class LayoutIterator
00054 {
00055 public:
00057   LayoutIterator(){;}
00058 
00059   LayoutIterator(const BoxLayout& a_layout)
00060   {
00061         *this = a_layout.layoutIterator();
00062   }
00063   // default copy and null constructor should be fine
00064   // not useful to someone using the iterator.  Used by
00065   // other classes in Chombo.  Could make it private and
00066   // let BoxLayout have access....
00067   ~LayoutIterator() {;}
00068 
00070   const LayoutIndex& operator()() const;
00072   LayoutIndex i() const { return this ->operator()();}
00073 
00075   void operator++();
00077   void incr(){ ++(*this);}
00078 
00080   bool ok() const;
00081 
00083   void begin();
00084 
00086   void reset();
00087 
00089 
00090   void end();
00091 
00092 
00093 
00094 protected:
00095 
00096   friend class BoxLayout;
00097 
00098   LayoutIterator(const BoxLayout& boxlayout, const int* layoutID);
00099 
00100   BoxLayout m_layout;
00101 
00102   unsigned int m_index;
00103 
00104   LayoutIndex m_current;
00105 
00106 };
00107 
00108 
00109 #ifndef WRAPPER
00110 
00111 inline const LayoutIndex& LayoutIterator::operator()() const
00112 {
00113   assert(ok());
00114   return m_current;
00115 }
00116 
00117 inline void LayoutIterator::operator++()
00118 {
00119   ++m_index;
00120   if(ok())
00121     m_current.m_index = (*(m_layout.m_boxes))[m_index].index;
00122 }
00123 
00124 inline bool LayoutIterator::ok() const
00125 {
00126   return m_index < m_layout.size();
00127 }
00128 
00129 
00130 inline void LayoutIterator::begin()
00131 {
00132   m_index = 0;
00133   if(ok())
00134     m_current.m_index = (*(m_layout.m_boxes))[m_index].index;
00135 }
00136 #endif /*WRAPPER*/
00137 
00138 #endif

Generated on Wed Jun 2 13:53:33 2004 for Chombo&INSwithParticles by doxygen 1.3.2