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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2271 - (hide 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 jfenwick 1865
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 jfenwick 2271 getSampleDataRW(ValueType::size_type sampleNo);
46 jfenwick 1865
47 jfenwick 2271 ESCRIPT_DLL_API
48     const double*
49     getSampleDataRO(ValueType::size_type sampleNo) const;
50 jfenwick 1865
51     /**
52 jfenwick 2271 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 jfenwick 1865 \brief Provide access to underlying storage. Internal use only!
63     */
64 jfenwick 2271 // 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 jfenwick 1865 ESCRIPT_DLL_API
73     virtual DataTypes::ValueType&
74 jfenwick 2271 getVectorRW()=0;
75 jfenwick 1865
76 jfenwick 2271
77 jfenwick 1865 ESCRIPT_DLL_API
78     virtual const DataTypes::ValueType&
79 jfenwick 2271 getVectorRO() const=0;
80 jfenwick 1865
81 jfenwick 2271
82 jfenwick 1865 /**
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 jfenwick 2271 getDataAtOffsetRO(DataTypes::ValueType::size_type i) const;
102 jfenwick 1865
103    
104     ESCRIPT_DLL_API
105     DataTypes::ValueType::reference
106 jfenwick 2271 getDataAtOffsetRW(DataTypes::ValueType::size_type i);
107 jfenwick 1865
108     ESCRIPT_DLL_API
109     DataReady_ptr
110     resolve();
111    
112     };
113    
114    
115     inline
116     DataAbstract::ValueType::value_type*
117 jfenwick 2271 DataReady::getSampleDataRW(ValueType::size_type sampleNo)
118 jfenwick 1865 {
119 jfenwick 2271 return &(getVectorRW()[getPointOffset(sampleNo,0)]); // exclusive write checks will be done in getVectorRW()
120 jfenwick 1865 }
121    
122 jfenwick 2271 inline const double*
123     DataReady::getSampleDataRO(ValueType::size_type sampleNo) const
124     {
125     return &(getVectorRO()[getPointOffset(sampleNo,0)]);
126     }
127 jfenwick 1865
128 jfenwick 2271
129 jfenwick 1865 inline
130     DataTypes::ValueType::const_reference
131 jfenwick 2271 DataReady::getDataAtOffsetRO(DataTypes::ValueType::size_type i) const
132 jfenwick 1865 {
133 jfenwick 2271 return getVectorRO()[i];
134 jfenwick 1865 }
135    
136     inline
137     DataTypes::ValueType::reference
138 jfenwick 2271 DataReady::getDataAtOffsetRW(DataTypes::ValueType::size_type i) // exclusive write checks will be done in getVectorRW()
139 jfenwick 1865 {
140 jfenwick 2271 return getVectorRW()[i];
141 jfenwick 1865 }
142    
143    
144    
145     }
146    
147     #endif

  ViewVC Help
Powered by ViewVC 1.1.26