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 _DATAINDEX_H_ 00012 #define _DATAINDEX_H_ 00013 00014 #include <cstdlib> 00015 #include "NamespaceHeader.H" 00016 00017 #ifndef WRAPPER 00018 class BoxLayout; 00019 00020 class DataIterator; 00021 class LayoutIterator; 00022 00023 #endif /* WRAPPER */ 00024 00025 00027 class LayoutIndex 00028 { 00029 public: 00031 LayoutIndex(); 00032 00033 ~LayoutIndex() 00034 {} 00035 00036 // default copy and assign should be fine. 00037 00039 bool operator == (const LayoutIndex& a_rhs) const; 00040 00041 bool eq(const LayoutIndex& a_rhs) const 00042 { 00043 return *this == a_rhs; 00044 } 00045 00047 bool operator != (const LayoutIndex& a_rhs) const 00048 { 00049 return !(*this == a_rhs); 00050 } 00051 00053 bool isNull() const; 00054 00055 // not user function. breaks design encapsulation. method not intended for 00056 // users. The alternative is to make this class a friend of BoxLayoutData<T>, 00057 // which implicitly makes this class templated, which makes no bloody sense. 00058 // The behaviour of this method is undefined for users. bvs 00059 int intCode() const; 00060 00061 00062 private: 00063 friend class DataIterator; 00064 friend class LayoutIterator; 00065 friend class TimedDataIterator; 00066 friend class NeighborIterator; 00067 friend class BoxLayout; 00068 friend class DataIndex; 00069 00070 int m_index; 00071 const int* m_layoutIntPtr; 00072 00073 LayoutIndex(int a_index, 00074 const int* a_layoutID) 00075 : 00076 m_index(a_index), 00077 m_layoutIntPtr(a_layoutID) 00078 {} 00079 }; 00080 00081 class DataIndex : public LayoutIndex 00082 { 00083 public: 00084 explicit DataIndex(const LayoutIndex& a_promotion) 00085 : 00086 LayoutIndex(a_promotion) 00087 {} 00088 00089 DataIndex() 00090 : 00091 LayoutIndex() 00092 {} 00093 00094 ~DataIndex() 00095 {} 00096 00097 00098 private: 00099 friend class LayoutIterator; 00100 friend class DataIterator; 00101 friend class TimedDataIterator; 00102 friend class NeighborIterator; 00103 friend class BoxLayout; 00104 friend class Copier; 00105 00106 DataIndex(int a_index, 00107 const int* a_layoutID) 00108 : 00109 LayoutIndex(a_index, a_layoutID) 00110 {} 00111 }; 00112 00113 #ifndef WRAPPER 00114 inline LayoutIndex::LayoutIndex() 00115 : 00116 m_index(0), 00117 m_layoutIntPtr(NULL) 00118 {} 00119 00120 inline bool LayoutIndex::operator == (const LayoutIndex& a_rhs) const 00121 { 00122 return (m_index == a_rhs.m_index); 00123 } 00124 00125 inline int LayoutIndex::intCode() const 00126 { 00127 return m_index; 00128 } 00129 00130 inline bool LayoutIndex::isNull() const 00131 { 00132 return m_layoutIntPtr == NULL; 00133 } 00134 #endif 00135 00136 #include "NamespaceFooter.H" 00137 #endif