escript  Revision_
DataReady.h
Go to the documentation of this file.
00001 
00002 /*****************************************************************************
00003 *
00004 * Copyright (c) 2003-2014 by University of Queensland
00005 * http://www.uq.edu.au
00006 *
00007 * Primary Business: Queensland, Australia
00008 * Licensed under the Open Software License version 3.0
00009 * http://www.opensource.org/licenses/osl-3.0.php
00010 *
00011 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
00012 * Development 2012-2013 by School of Earth Sciences
00013 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
00014 *
00015 *****************************************************************************/
00016 
00017 
00018 #if !defined escript_DataReady_20081008_H
00019 #define escript_DataReady_20081008_H
00020 #include "system_dep.h"
00021 
00022 #include "DataAbstract.h"
00023 
00024 namespace escript {
00025 
00026 // Anything which requires getVector should be moved down here
00027 
00028 
00029 
00035 class DataReady : public DataAbstract
00036 {
00037 typedef DataAbstract parent; 
00038 public:
00039    DataReady(const FunctionSpace& what, const ShapeType& shape, bool isDataEmpty=false);
00040    ~DataReady(){};
00041 
00042 
00043 
00048   ESCRIPT_DLL_API
00049   double*
00050   getSampleDataRW(ValueType::size_type sampleNo);
00051 
00052   ESCRIPT_DLL_API
00053   const double*
00054   getSampleDataRO(ValueType::size_type sampleNo) const;
00055 
00060   ESCRIPT_DLL_API
00061   virtual DataTypes::ValueType&
00062   getVectorRW()=0;
00063 
00064 
00065   ESCRIPT_DLL_API
00066   virtual const DataTypes::ValueType&
00067   getVectorRO() const=0;
00068 
00074   ESCRIPT_DLL_API
00075   virtual bool
00076   hasNaN() const=0;
00077 
00085   ESCRIPT_DLL_API
00086   virtual
00087   void
00088   setSlice(const DataAbstract* value,
00089            const DataTypes::RegionType& region) = 0;
00090 
00091 
00095   ESCRIPT_DLL_API
00096   DataTypes::ValueType::const_reference
00097   getDataAtOffsetRO(DataTypes::ValueType::size_type i) const;
00098 
00099 
00100   ESCRIPT_DLL_API
00101   DataTypes::ValueType::reference
00102   getDataAtOffsetRW(DataTypes::ValueType::size_type i);
00103 
00104   ESCRIPT_DLL_API
00105   DataReady_ptr 
00106   resolve();
00107 
00108 };
00109 
00110 
00111 inline
00112 DataAbstract::ValueType::value_type*
00113 DataReady::getSampleDataRW(ValueType::size_type sampleNo)
00114 {
00115   return &(getVectorRW()[getPointOffset(sampleNo,0)]);      // exclusive write checks will be done in getVectorRW()
00116 }
00117 
00118 inline const double*
00119 DataReady::getSampleDataRO(ValueType::size_type sampleNo) const
00120 {
00121   return &(getVectorRO()[getPointOffset(sampleNo,0)]);      
00122 }
00123 
00124 
00125 inline
00126 DataTypes::ValueType::const_reference
00127 DataReady::getDataAtOffsetRO(DataTypes::ValueType::size_type i) const
00128 {
00129    return getVectorRO()[i];
00130 }
00131 
00132 inline
00133 DataTypes::ValueType::reference
00134 DataReady::getDataAtOffsetRW(DataTypes::ValueType::size_type i) // exclusive write checks will be done in getVectorRW()
00135 {
00136    return getVectorRW()[i];
00137 }
00138 
00139 
00140 
00141 }
00142 
00143 #endif