/[escript]/trunk/escript/src/DataReady.h
ViewVC logotype

Contents of /trunk/escript/src/DataReady.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4154 - (show annotations)
Tue Jan 22 09:30:23 2013 UTC (6 years, 8 months ago) by jfenwick
File MIME type: text/plain
File size: 3184 byte(s)
Round 1 of copyright fixes
1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2013 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 since 2012 by School of Earth Sciences
13 *
14 *****************************************************************************/
15
16
17 #if !defined escript_DataReady_20081008_H
18 #define escript_DataReady_20081008_H
19 #include "system_dep.h"
20
21 #include "DataAbstract.h"
22
23 namespace escript {
24
25 // Anything which requires getVector should be moved down here
26
27
28
29 /**
30 \class DataReady
31 Base class for Data which do not need to be resolved.
32 Internally this means they have getVectorRO and getVectorRW methods.
33 */
34 class DataReady : public DataAbstract
35 {
36 typedef DataAbstract parent;
37 public:
38 DataReady(const FunctionSpace& what, const ShapeType& shape, bool isDataEmpty=false);
39 ~DataReady(){};
40
41
42
43 /**
44 \brief
45 Return the sample data for the given sample number.
46 */
47 ESCRIPT_DLL_API
48 double*
49 getSampleDataRW(ValueType::size_type sampleNo);
50
51 ESCRIPT_DLL_API
52 const double*
53 getSampleDataRO(ValueType::size_type sampleNo) const;
54
55 /**
56 \brief Provide access to underlying storage. Internal use only!
57 */
58
59 ESCRIPT_DLL_API
60 virtual DataTypes::ValueType&
61 getVectorRW()=0;
62
63
64 ESCRIPT_DLL_API
65 virtual const DataTypes::ValueType&
66 getVectorRO() const=0;
67
68 /**
69 \brief return true if data contains NaN.
70 \warning This is dependent on the ability to reliably detect NaNs on your compiler.
71 See the nancheck function in LocalOps for details.
72 */
73 ESCRIPT_DLL_API
74 virtual bool
75 hasNaN() const=0;
76
77 /**
78 \brief
79 Copy the specified region from the given object.
80
81 \param value - Input - Data to copy from
82 \param region - Input - Region to copy.
83 */
84 ESCRIPT_DLL_API
85 virtual
86 void
87 setSlice(const DataAbstract* value,
88 const DataTypes::RegionType& region) = 0;
89
90
91 /**
92 \brief get a reference to the beginning of a data point
93 */
94 ESCRIPT_DLL_API
95 DataTypes::ValueType::const_reference
96 getDataAtOffsetRO(DataTypes::ValueType::size_type i) const;
97
98
99 ESCRIPT_DLL_API
100 DataTypes::ValueType::reference
101 getDataAtOffsetRW(DataTypes::ValueType::size_type i);
102
103 ESCRIPT_DLL_API
104 DataReady_ptr
105 resolve();
106
107 };
108
109
110 inline
111 DataAbstract::ValueType::value_type*
112 DataReady::getSampleDataRW(ValueType::size_type sampleNo)
113 {
114 return &(getVectorRW()[getPointOffset(sampleNo,0)]); // exclusive write checks will be done in getVectorRW()
115 }
116
117 inline const double*
118 DataReady::getSampleDataRO(ValueType::size_type sampleNo) const
119 {
120 return &(getVectorRO()[getPointOffset(sampleNo,0)]);
121 }
122
123
124 inline
125 DataTypes::ValueType::const_reference
126 DataReady::getDataAtOffsetRO(DataTypes::ValueType::size_type i) const
127 {
128 return getVectorRO()[i];
129 }
130
131 inline
132 DataTypes::ValueType::reference
133 DataReady::getDataAtOffsetRW(DataTypes::ValueType::size_type i) // exclusive write checks will be done in getVectorRW()
134 {
135 return getVectorRW()[i];
136 }
137
138
139
140 }
141
142 #endif

  ViewVC Help
Powered by ViewVC 1.1.26