00001 00002 /******************************************************* 00003 * 00004 * Copyright (c) 2003-2009 by University of Queensland 00005 * Earth Systems Science Computational Center (ESSCC) 00006 * http://www.uq.edu.au/esscc 00007 * 00008 * Primary Business: Queensland, Australia 00009 * Licensed under the Open Software License version 3.0 00010 * http://www.opensource.org/licenses/osl-3.0.php 00011 * 00012 *******************************************************/ 00013 00014 00015 #if !defined escript_DataReady_20081008_H 00016 #define escript_DataReady_20081008_H 00017 #include "system_dep.h" 00018 00019 #include "DataAbstract.h" 00020 00021 namespace escript { 00022 00023 // Anything which requires getVector should be moved down here 00024 00025 00026 00032 class DataReady : public DataAbstract 00033 { 00034 typedef DataAbstract parent; 00035 public: 00036 DataReady(const FunctionSpace& what, const ShapeType& shape, bool isDataEmpty=false); 00037 ~DataReady(){}; 00038 00039 00040 00045 ESCRIPT_DLL_API 00046 double* 00047 getSampleDataRW(ValueType::size_type sampleNo); 00048 00049 ESCRIPT_DLL_API 00050 const double* 00051 getSampleDataRO(ValueType::size_type sampleNo) const; 00052 00056 ESCRIPT_DLL_API 00057 size_t 00058 getSampleBufferSize() const 00059 { 00060 return 1; 00061 } 00062 00067 ESCRIPT_DLL_API 00068 virtual DataTypes::ValueType& 00069 getVectorRW()=0; 00070 00071 00072 ESCRIPT_DLL_API 00073 virtual const DataTypes::ValueType& 00074 getVectorRO() const=0; 00075 00076 00084 ESCRIPT_DLL_API 00085 virtual 00086 void 00087 setSlice(const DataAbstract* value, 00088 const DataTypes::RegionType& region) = 0; 00089 00090 00094 ESCRIPT_DLL_API 00095 DataTypes::ValueType::const_reference 00096 getDataAtOffsetRO(DataTypes::ValueType::size_type i) const; 00097 00098 00099 ESCRIPT_DLL_API 00100 DataTypes::ValueType::reference 00101 getDataAtOffsetRW(DataTypes::ValueType::size_type i); 00102 00103 ESCRIPT_DLL_API 00104 DataReady_ptr 00105 resolve(); 00106 00107 }; 00108 00109 00110 inline 00111 DataAbstract::ValueType::value_type* 00112 DataReady::getSampleDataRW(ValueType::size_type sampleNo) 00113 { 00114 return &(getVectorRW()[getPointOffset(sampleNo,0)]); // exclusive write checks will be done in getVectorRW() 00115 } 00116 00117 inline const double* 00118 DataReady::getSampleDataRO(ValueType::size_type sampleNo) const 00119 { 00120 return &(getVectorRO()[getPointOffset(sampleNo,0)]); 00121 } 00122 00123 00124 inline 00125 DataTypes::ValueType::const_reference 00126 DataReady::getDataAtOffsetRO(DataTypes::ValueType::size_type i) const 00127 { 00128 return getVectorRO()[i]; 00129 } 00130 00131 inline 00132 DataTypes::ValueType::reference 00133 DataReady::getDataAtOffsetRW(DataTypes::ValueType::size_type i) // exclusive write checks will be done in getVectorRW() 00134 { 00135 return getVectorRW()[i]; 00136 } 00137 00138 00139 00140 } 00141 00142 #endif