ESYS13  Revision_
DataReady.h
Go to the documentation of this file.
00001 
00002 /*******************************************************
00003 *
00004 * Copyright (c) 2003-2012 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 
00057   ESCRIPT_DLL_API
00058   virtual DataTypes::ValueType&
00059   getVectorRW()=0;
00060 
00061 
00062   ESCRIPT_DLL_API
00063   virtual const DataTypes::ValueType&
00064   getVectorRO() const=0;
00065 
00071   ESCRIPT_DLL_API
00072   virtual bool
00073   hasNaN() const=0;
00074 
00082   ESCRIPT_DLL_API
00083   virtual
00084   void
00085   setSlice(const DataAbstract* value,
00086            const DataTypes::RegionType& region) = 0;
00087 
00088 
00092   ESCRIPT_DLL_API
00093   DataTypes::ValueType::const_reference
00094   getDataAtOffsetRO(DataTypes::ValueType::size_type i) const;
00095 
00096 
00097   ESCRIPT_DLL_API
00098   DataTypes::ValueType::reference
00099   getDataAtOffsetRW(DataTypes::ValueType::size_type i);
00100 
00101   ESCRIPT_DLL_API
00102   DataReady_ptr 
00103   resolve();
00104 
00105 };
00106 
00107 
00108 inline
00109 DataAbstract::ValueType::value_type*
00110 DataReady::getSampleDataRW(ValueType::size_type sampleNo)
00111 {
00112   return &(getVectorRW()[getPointOffset(sampleNo,0)]);      // exclusive write checks will be done in getVectorRW()
00113 }
00114 
00115 inline const double*
00116 DataReady::getSampleDataRO(ValueType::size_type sampleNo) const
00117 {
00118   return &(getVectorRO()[getPointOffset(sampleNo,0)]);      
00119 }
00120 
00121 
00122 inline
00123 DataTypes::ValueType::const_reference
00124 DataReady::getDataAtOffsetRO(DataTypes::ValueType::size_type i) const
00125 {
00126    return getVectorRO()[i];
00127 }
00128 
00129 inline
00130 DataTypes::ValueType::reference
00131 DataReady::getDataAtOffsetRW(DataTypes::ValueType::size_type i) // exclusive write checks will be done in getVectorRW()
00132 {
00133    return getVectorRW()[i];
00134 }
00135 
00136 
00137 
00138 }
00139 
00140 #endif