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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2271 - (show annotations)
Mon Feb 16 05:08:29 2009 UTC (10 years, 8 months ago) by jfenwick
File MIME type: text/plain
File size: 3074 byte(s)
Merging version 2269 to trunk

1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2008 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 ...Purpose...
29 */
30 class DataReady : public DataAbstract
31 {
32 typedef DataAbstract parent;
33 public:
34 DataReady(const FunctionSpace& what, const ShapeType& shape, bool isDataEmpty=false);
35 ~DataReady(){};
36
37
38
39 /**
40 \brief
41 Return the sample data for the given sample number.
42 */
43 ESCRIPT_DLL_API
44 double*
45 getSampleDataRW(ValueType::size_type sampleNo);
46
47 ESCRIPT_DLL_API
48 const double*
49 getSampleDataRO(ValueType::size_type sampleNo) const;
50
51 /**
52 This function is required primarily for LazyData. For ReadyData it returns 1. (Behaviour subject to change).
53 */
54 ESCRIPT_DLL_API
55 size_t
56 getSampleBufferSize() const
57 {
58 return 1;
59 }
60
61 /**
62 \brief Provide access to underlying storage. Internal use only!
63 */
64 // ESCRIPT_DLL_API
65 // virtual DataTypes::ValueType&
66 // getVector()=0;
67 //
68 // ESCRIPT_DLL_API
69 // virtual const DataTypes::ValueType&
70 // getVector() const=0;
71
72 ESCRIPT_DLL_API
73 virtual DataTypes::ValueType&
74 getVectorRW()=0;
75
76
77 ESCRIPT_DLL_API
78 virtual const DataTypes::ValueType&
79 getVectorRO() const=0;
80
81
82 /**
83 \brief
84 Copy the specified region from the given object.
85
86 \param value - Input - Data to copy from
87 \param region - Input - Region to copy.
88 */
89 ESCRIPT_DLL_API
90 virtual
91 void
92 setSlice(const DataAbstract* value,
93 const DataTypes::RegionType& region) = 0;
94
95
96 /**
97 \brief get a reference to the beginning of a data point
98 */
99 ESCRIPT_DLL_API
100 DataTypes::ValueType::const_reference
101 getDataAtOffsetRO(DataTypes::ValueType::size_type i) const;
102
103
104 ESCRIPT_DLL_API
105 DataTypes::ValueType::reference
106 getDataAtOffsetRW(DataTypes::ValueType::size_type i);
107
108 ESCRIPT_DLL_API
109 DataReady_ptr
110 resolve();
111
112 };
113
114
115 inline
116 DataAbstract::ValueType::value_type*
117 DataReady::getSampleDataRW(ValueType::size_type sampleNo)
118 {
119 return &(getVectorRW()[getPointOffset(sampleNo,0)]); // exclusive write checks will be done in getVectorRW()
120 }
121
122 inline const double*
123 DataReady::getSampleDataRO(ValueType::size_type sampleNo) const
124 {
125 return &(getVectorRO()[getPointOffset(sampleNo,0)]);
126 }
127
128
129 inline
130 DataTypes::ValueType::const_reference
131 DataReady::getDataAtOffsetRO(DataTypes::ValueType::size_type i) const
132 {
133 return getVectorRO()[i];
134 }
135
136 inline
137 DataTypes::ValueType::reference
138 DataReady::getDataAtOffsetRW(DataTypes::ValueType::size_type i) // exclusive write checks will be done in getVectorRW()
139 {
140 return getVectorRW()[i];
141 }
142
143
144
145 }
146
147 #endif

  ViewVC Help
Powered by ViewVC 1.1.26