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 _ARRAYVIEWDATA_H_ 00012 #define _ARRAYVIEWDATA_H_ 00013 00014 #include "REAL.H" 00015 #include "BaseFab.H" 00016 #include "FArrayBox.H" 00017 #include "LayoutData.H" 00018 #include "NamespaceHeader.H" 00019 00020 /// Special LayoutData type for use with ArrayView 00021 /** ArrayViewData is a wrapper around LayoutData for BaseFab<Real> or 00022 * FArrayBox for use in ArrayView. It provides random access to the 00023 * individual FABs and the ability to directly set the data in them. It is 00024 * intended to work only in ArrayView. Any other attept to use this class 00025 * is unsupported. 00026 */ 00027 00028 class ArrayViewData 00029 { 00030 public: 00031 ArrayViewData() 00032 : 00033 m_layoutdata_ptr(NULL) 00034 {} 00035 00036 ~ArrayViewData() 00037 {} 00038 00039 ArrayViewData(LayoutData<BaseFab<Real> >* a_layoutdata_ptr) 00040 : 00041 m_layoutdata_ptr(a_layoutdata_ptr) 00042 {} 00043 00044 ArrayViewData(LayoutData<FArrayBox>* a_layoutdata_ptr) 00045 : 00046 m_layoutdata_ptr((LayoutData<BaseFab<Real> >*) a_layoutdata_ptr) 00047 {} 00048 00049 /// Access a single FAB in the LayoutData using its internal index 00050 BaseFab<Real>& operator[](int a_elem) 00051 { 00052 return *(m_layoutdata_ptr->m_vector[a_elem]); 00053 } 00054 00055 /// Substitute a different FAB into the LayoutData 00056 /** The caller is responsible for managing the memory used by the FAB that 00057 * is being replaced. 00058 */ 00059 void set(int a_elem, 00060 BaseFab<Real>* a_fab_ptr) 00061 { 00062 m_layoutdata_ptr->m_vector[a_elem] = a_fab_ptr; 00063 } 00064 00065 00066 private: 00067 LayoutData<BaseFab<Real> >* m_layoutdata_ptr; 00068 }; 00069 00070 #include "NamespaceFooter.H" 00071 #endif