00001 #ifdef CH_LANG_CC
00002
00003
00004
00005
00006
00007
00008
00009 #endif
00010
00011 #ifndef _DATAINDEX_H_
00012 #define _DATAINDEX_H_
00013
00014 #include <cstdlib>
00015 #include <iostream>
00016 #include "MayDay.H"
00017 #include "parstream.H"
00018 #include "NamespaceHeader.H"
00019
00020 #ifndef WRAPPER
00021 class BoxLayout;
00022
00023 class DataIterator;
00024 class LayoutIterator;
00025
00026 #endif
00027
00028 using std::endl;
00029
00030 class LayoutIndex
00031 {
00032 public:
00033
00034 LayoutIndex();
00035
00036 virtual ~LayoutIndex()
00037 {}
00038
00039
00040
00041
00042 bool operator == (const LayoutIndex& a_rhs) const;
00043
00044 bool eq(const LayoutIndex& a_rhs) const
00045 {
00046 return *this == a_rhs;
00047 }
00048
00049
00050 bool operator != (const LayoutIndex& a_rhs) const
00051 {
00052 return !(*this == a_rhs);
00053 }
00054
00055
00056 bool isNull() const;
00057
00058
00059
00060
00061
00062 int intCode() const;
00063
00064 int datInd() const
00065 {
00066 #ifdef CH_MPI
00067 return m_datInd;
00068 #else
00069
00070 return m_index;
00071 #endif
00072 }
00073
00074 LayoutIndex(const LayoutIndex& a_input)
00075 {
00076 m_index = a_input.m_index;
00077 m_datInd = a_input.m_datInd;
00078 m_layoutIntPtr = a_input.m_layoutIntPtr;
00079 }
00080
00081
00082
00083
00084 virtual void output() const
00085 {
00086 pout() << "(" << m_index << "," << m_datInd << ")" << endl;
00087 }
00088
00089 private:
00090 friend class DataIterator;
00091 friend class LayoutIterator;
00092 friend class TimedDataIterator;
00093 friend class NeighborIterator;
00094 friend class BoxLayout;
00095 friend class DataIndex;
00096 friend class DisjointBoxLayout;
00097
00098 int m_index;
00099 int m_datInd;
00100 const int* m_layoutIntPtr;
00101
00102 LayoutIndex(int a_indexIntoBoxes,
00103 int a_indexIntoData,
00104 const int* a_layoutID)
00105 :
00106 m_index (a_indexIntoBoxes),
00107 m_datInd(a_indexIntoData),
00108 m_layoutIntPtr(a_layoutID)
00109 {}
00110 };
00111
00112 class DataIndex : public LayoutIndex
00113 {
00114 public:
00115 explicit DataIndex(const LayoutIndex& a_promotion)
00116 :
00117 LayoutIndex(a_promotion)
00118 {}
00119 DataIndex()
00120 :
00121 LayoutIndex()
00122 {}
00123
00124 virtual ~DataIndex()
00125 {}
00126
00127 private:
00128 friend class LayoutIterator;
00129 friend class DataIterator;
00130 friend class TimedDataIterator;
00131 friend class NeighborIterator;
00132 friend class BoxLayout;
00133 friend class Copier;
00134
00135 DataIndex(int a_indexIntoBox,
00136 int a_indexIntoData,
00137 const int* a_layoutID)
00138 :
00139 LayoutIndex(a_indexIntoBox, a_indexIntoData, a_layoutID)
00140 {
00141 }
00142 };
00143
00144 #ifndef WRAPPER
00145 inline LayoutIndex::LayoutIndex()
00146 :
00147 m_index(0),
00148 m_layoutIntPtr(NULL)
00149 {
00150 }
00151
00152 inline bool LayoutIndex::operator == (const LayoutIndex& a_rhs) const
00153 {
00154 return (m_index == a_rhs.m_index);
00155 }
00156
00157 inline int LayoutIndex::intCode() const
00158 {
00159 return m_index;
00160 }
00161
00162 inline bool LayoutIndex::isNull() const
00163 {
00164 return m_layoutIntPtr == NULL;
00165 }
00166 #endif
00167
00168 #include "NamespaceFooter.H"
00169 #endif