FieldWrapper.h
00001 #ifndef gridripper_amr1d_FieldWrapper_h
00002 #define gridripper_amr1d_FieldWrapper_h
00003
00004 #include <gridripper/config.h>
00005
00006 namespace gridripper { namespace amr1d {
00007
00008 using namespace std;
00009
00017 class FieldWrapper
00018 {
00019 private:
00020 GReal_t* theData;
00021
00022 int theSize;
00023
00024 public:
00025 const bool ownsData;
00026
00027 protected:
00029 FieldWrapper(GReal_t* d, int n):
00030 theData(d), theSize(n), ownsData(false) {
00031 }
00032
00034 FieldWrapper(int n): theSize(n), ownsData(true) {
00035 theData = new GReal_t[n];
00036 }
00037
00038 public:
00040 FieldWrapper(const FieldWrapper& other);
00041
00042 virtual ~FieldWrapper();
00043
00044 virtual void set(const FieldWrapper& other);
00045
00046 GReal_t* data() {
00047 return theData;
00048 }
00049
00050 const GReal_t* data() const {
00051 return theData;
00052 }
00053
00054 unsigned size() const {
00055 return theSize;
00056 }
00057
00062 bool resize(int n);
00063
00064 virtual FieldWrapper* cloneFieldWrapper() const {
00065 return new FieldWrapper(*this);
00066 }
00067
00069 FieldWrapper& operator =(const FieldWrapper& a) {
00070 set(a);
00071 return *this;
00072 }
00073 };
00074
00075 } }
00076
00077 #endif