escript  Revision_4925
DataReady.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2014 by University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development 2012-2013 by School of Earth Sciences
13 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16 
17 
18 #if !defined escript_DataReady_20081008_H
19 #define escript_DataReady_20081008_H
20 #include "system_dep.h"
21 
22 #include "DataAbstract.h"
23 
24 namespace escript {
25 
26 // Anything which requires getVector should be moved down here
27 
28 
29 
35 class DataReady : public DataAbstract
36 {
38 public:
39  DataReady(const FunctionSpace& what, const ShapeType& shape, bool isDataEmpty=false);
41 
42 
43 
49  double*
51 
53  const double*
54  getSampleDataRO(ValueType::size_type sampleNo) const;
55 
61  virtual DataTypes::ValueType&
62  getVectorRW()=0;
63 
64 
66  virtual const DataTypes::ValueType&
67  getVectorRO() const=0;
68 
75  virtual bool
76  hasNaN() const=0;
77 
86  virtual
87  void
88  setSlice(const DataAbstract* value,
89  const DataTypes::RegionType& region) = 0;
90 
91 
98 
99 
103 
106  resolve();
107 
108 };
109 
110 
111 inline
114 {
115  return &(getVectorRW()[getPointOffset(sampleNo,0)]); // exclusive write checks will be done in getVectorRW()
116 }
117 
118 inline const double*
120 {
121  return &(getVectorRO()[getPointOffset(sampleNo,0)]);
122 }
123 
124 
125 inline
128 {
129  return getVectorRO()[i];
130 }
131 
132 inline
134 DataReady::getDataAtOffsetRW(DataTypes::ValueType::size_type i) // exclusive write checks will be done in getVectorRW()
135 {
136  return getVectorRW()[i];
137 }
138 
139 
140 
141 }
142 
143 #endif
Give a short description of what FunctionSpace does.
Definition: FunctionSpace.h:46
DataVector implements an arbitrarily long vector of data values. DataVector is the underlying data co...
Definition: DataVector.h:44
DataTypes::ShapeType ShapeType
Definition: DataAbstract.h:67
Definition: DataReady.h:35
std::vector< std::pair< int, int > > RegionType
Definition: DataTypes.h:39
DataTypes::ValueType::reference getDataAtOffsetRW(DataTypes::ValueType::size_type i)
Definition: DataReady.h:134
double * getSampleDataRW(ValueType::size_type sampleNo)
Return the sample data for the given sample number.
Definition: DataReady.h:113
virtual DataTypes::ValueType & getVectorRW()=0
Provide access to underlying storage. Internal use only!
virtual void setSlice(const DataAbstract *value, const DataTypes::RegionType &region)=0
Copy the specified region from the given object.
virtual bool hasNaN() const =0
return true if data contains NaN.
DataReady(const FunctionSpace &what, const ShapeType &shape, bool isDataEmpty=false)
Definition: DataReady.cpp:22
const ElementType & const_reference
Definition: DataVector.h:62
const double * getSampleDataRO(ValueType::size_type sampleNo) const
Definition: DataReady.h:119
DataTypes::ValueType::const_reference getDataAtOffsetRO(DataTypes::ValueType::size_type i) const
get a reference to the beginning of a data point
Definition: DataReady.h:127
virtual const DataTypes::ValueType & getVectorRO() const =0
~DataReady()
Definition: DataReady.h:40
#define ESCRIPT_DLL_API
Definition: escriptcore/src/system_dep.h:64
ElementType & reference
Definition: DataVector.h:61
DataReady_ptr resolve()
Return a data object with all points resolved.
Definition: DataReady.cpp:29
ElementType value_type
Definition: DataVector.h:59
Definition: DataAbstract.h:61
boost::shared_ptr< DataReady > DataReady_ptr
Definition: DataAbstract.h:56
long size_type
Definition: DataVector.h:60
virtual ValueType::size_type getPointOffset(int sampleNo, int dataPointNo) const =0
Return the offset for the given sample. This returns the offset for the given point into the containe...
DataAbstract parent
Definition: DataReady.h:37