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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.26