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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2548 - (show annotations)
Mon Jul 20 06:20:06 2009 UTC (10 years, 3 months ago) by jfenwick
File MIME type: text/plain
File size: 3020 byte(s)
Updating copyright notices
1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2009 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 This function is required primarily for LazyData. For ReadyData it returns 1. (Behaviour subject to change).
55 */
56 ESCRIPT_DLL_API
57 size_t
58 getSampleBufferSize() const
59 {
60 return 1;
61 }
62
63 /**
64 \brief Provide access to underlying storage. Internal use only!
65 */
66
67 ESCRIPT_DLL_API
68 virtual DataTypes::ValueType&
69 getVectorRW()=0;
70
71
72 ESCRIPT_DLL_API
73 virtual const DataTypes::ValueType&
74 getVectorRO() const=0;
75
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