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 _LOHISIDE_H_ 00012 #define _LOHISIDE_H_ 00013 #include "BaseNamespaceHeader.H" 00014 00015 /// Encapsulation of high or low side. 00016 /** 00017 Encapsulation of high or low side. 00018 */ 00019 class Side 00020 { 00021 public: 00022 /// 00023 /** 00024 Lo is the low side.<br> 00025 Hi is the high side. 00026 */ 00027 enum LoHiSide 00028 { 00029 Invalid=-1, 00030 Lo=0, 00031 Hi, 00032 NUMSIDES 00033 }; 00034 00035 /** 00036 Constructor. 00037 */ 00038 Side() 00039 { 00040 } 00041 00042 /** 00043 Destructor. 00044 */ 00045 ~Side() 00046 { 00047 } 00048 00049 /// 00050 /** 00051 Returns the other side. That is, swap Hi for Lo and vice versa. 00052 */ 00053 friend Side::LoHiSide flip(const Side::LoHiSide& a_side); 00054 00055 /// 00056 static Side::LoHiSide flip(const Side::LoHiSide& a_side); 00057 00058 /// 00059 /** 00060 Returns -1 for Lo Side, +1 for Hi Side. 00061 */ 00062 friend 00063 int sign(const Side::LoHiSide& a_side); 00064 }; 00065 00066 // needs a declaration outside the class (Stroustrup 11.5.1) 00067 int sign(const Side::LoHiSide& a_side); 00068 00069 /// Iterator for low and high side. 00070 /** 00071 SideIterator iterates over the values Side::Lo and Side::Hi. 00072 There are no adjustable parameters whatsoever. 00073 */ 00074 class SideIterator 00075 { 00076 public: 00077 /// 00078 /** 00079 Default, and only, constructor. 00080 */ 00081 SideIterator(); 00082 00083 /// 00084 /** 00085 Default destructor. 00086 */ 00087 ~SideIterator() 00088 {} 00089 00090 /** 00091 \name Modification functions 00092 */ 00093 /*@{*/ 00094 00095 /// 00096 /** 00097 Set the iterator to the first side. 00098 */ 00099 void begin(); 00100 00101 /// 00102 /** 00103 Set the iterator to the first side. 00104 */ 00105 void reset() 00106 { 00107 begin(); 00108 } 00109 00110 /// 00111 /** 00112 Advance the iterator to the next face. 00113 */ 00114 void next(); 00115 00116 /// 00117 /** 00118 Advance the iterator to the next face. 00119 */ 00120 void operator ++ (); 00121 00122 /*@}*/ 00123 00124 /** 00125 \name Access functions 00126 */ 00127 /*@{*/ 00128 00129 /// 00130 /** 00131 Returns the value of the side for the current iteration. 00132 */ 00133 Side::LoHiSide operator () () const; 00134 00135 /// 00136 /** 00137 Returns <tt>true</tt> if there is a next side, <tt>false</tt> if not. 00138 */ 00139 bool ok() const; 00140 00141 00142 private: 00143 int m_current; 00144 }; 00145 00146 #include "BaseNamespaceFooter.H" 00147 #endif