29 |
|
|
30 |
/** |
/** |
31 |
\brief |
\brief |
32 |
Creates the illusion of a full dataset accessible via sampleNo and dataPointNo. |
Simulates a full dataset accessible via sampleNo and dataPointNo. |
33 |
|
|
34 |
Description: |
Description: |
35 |
Creates the illusion of a full dataset accessible via sampleNo and |
Each data-point has an associated tag number, and a given tag can represent a |
36 |
dataPointNo. In reality a much smaller number of data-points is stored. |
range of dataPointNo and sampleNo. Each tag indexes only a single data-point. |
|
Each data-point has an associated key, thus a given key represents a specific |
|
|
range of dataPointNo and sampleNo. Each key indexes a single data-point. |
|
37 |
Thus only a single data-point needs to be stored for a range of sampleNo and |
Thus only a single data-point needs to be stored for a range of sampleNo and |
38 |
dataPointNo values. |
dataPointNo values. |
39 |
*/ |
*/ |
43 |
public: |
public: |
44 |
|
|
45 |
// |
// |
46 |
// Types for the lists of tags and values |
// Types for the lists of tags and values. |
47 |
typedef std::vector<int> TagListType; |
typedef std::vector<int> TagListType; |
48 |
typedef std::vector<DataArrayView> ValueListType; |
typedef std::vector<DataArrayView> ValueListType; |
49 |
typedef DataArrayView::ValueType ValueType; |
typedef DataArrayView::ValueType ValueType; |
50 |
|
|
51 |
// |
// |
52 |
// Map from the tag to an offset the the data array. |
// Map from a tag to an offset into the data array. |
53 |
typedef std::map<int, int> DataMapType; |
typedef std::map<int, int> DataMapType; |
54 |
|
|
55 |
/** |
/** |
58 |
|
|
59 |
Description: |
Description: |
60 |
Default constructor for DataTagged. Creates a DataTagged object for which |
Default constructor for DataTagged. Creates a DataTagged object for which |
61 |
the default data-point is a scalar data-point with value 0.0. Any given tag |
the only data-point is a scalar data-point with value 0.0. All tags |
62 |
will map to this data-point. |
will map to this single data-point. |
63 |
*/ |
*/ |
64 |
DataTagged(); |
DataTagged(); |
65 |
|
|
71 |
Constructor for DataTagged. |
Constructor for DataTagged. |
72 |
\param tagKeys - Input - A vector of integer keys. |
\param tagKeys - Input - A vector of integer keys. |
73 |
\param values - Input - A vector of DataArrayViews. If this is empty |
\param values - Input - A vector of DataArrayViews. If this is empty |
74 |
all tag values will be assigned a value of zero. If |
all tag values will be assigned a value of zero. If |
75 |
it contains one value all tag values will be assigned the |
it contains one value all tag values will be assigned the |
76 |
same value. Otherwise if there is a mismatch between |
same value. Otherwise if there is a mismatch between |
77 |
the number of keys and the number of values an exception |
the number of keys and the number of values an exception |
78 |
will be generated. |
will be generated. |
79 |
\param defaultValue - Input - Value returned if a requested tag doesn't exist. |
\param defaultValue - Input - Value returned if a requested tag doesn't exist. |
80 |
\param what - Input - A description of what this data represents. |
\param what - Input - A description of what this data represents. |
81 |
*/ |
*/ |
86 |
|
|
87 |
/** |
/** |
88 |
\brief |
\brief |
89 |
Alternative constructor for DataTagged objects. |
Alternative Constructor for DataTagged. |
90 |
|
|
91 |
Description: |
Description: |
92 |
Alternative Constructor for DataTagged objects. |
Alternative Constructor for DataTagged. |
93 |
\param what - Input - A description of what this data object represents. |
\param what - Input - A description of what this data object represents. |
94 |
\param shape - Input - the shape of each data-point. |
\param shape - Input - The shape of each data-point. |
95 |
\param tags - Input - array of tags, one for each sample number |
\param tags - Input - An array of tags, one for each sample number. |
96 |
\param data - the data values for each data-point. |
\param data - The data values for each tag. |
97 |
*/ |
*/ |
98 |
DataTagged(const FunctionSpace& what, |
DataTagged(const FunctionSpace& what, |
99 |
const DataArrayView::ShapeType &shape, |
const DataArrayView::ShapeType &shape, |
102 |
|
|
103 |
/** |
/** |
104 |
\brief |
\brief |
105 |
Slice constructor for DataTagged. |
Slice Constructor for DataTagged. |
106 |
|
|
107 |
Description: |
Description: |
108 |
Slice constructor for DataTagged. |
Slice Constructor for DataTagged. |
109 |
Copies a slice from another DataTagged object. |
Copies a slice from another DataTagged object. |
110 |
\param other - Input - DataTagged object to copy from. |
\param other - Input - DataTagged object to copy from. |
111 |
\param region - Input - region to copy. |
\param region - Input - Region to copy. |
112 |
*/ |
*/ |
113 |
DataTagged(const DataTagged& other, |
DataTagged(const DataTagged& other, |
114 |
const DataArrayView::RegionType& region); |
const DataArrayView::RegionType& region); |
115 |
|
|
116 |
/** |
/** |
117 |
\brief |
\brief |
118 |
Copy constructorfor DataTagged. |
Copy Constructor for DataTagged. |
119 |
Performs a deep copy from the given DataTagged object. |
Performs a deep copy from the given DataTagged object. |
120 |
*/ |
*/ |
121 |
DataTagged(const DataTagged& other); |
DataTagged(const DataTagged& other); |
122 |
|
|
123 |
/** |
/** |
124 |
\brief |
\brief |
125 |
|
Copy Constructor for DataTagged. |
126 |
Construct a tagged data from a DataConstant object. |
Construct a tagged data from a DataConstant object. |
127 |
The default data-point will be that held by the DataConstant object. |
The default value will be that held by the DataConstant object. |
128 |
*/ |
*/ |
129 |
DataTagged(const DataConstant& other); |
DataTagged(const DataConstant& other); |
130 |
|
|
133 |
getSampleDataByTag |
getSampleDataByTag |
134 |
|
|
135 |
Description: |
Description: |
136 |
Return the data-point for the given tag. All of the data for the entire |
Return the data-point for the given tag. All of the data for the |
137 |
sample should be visable via the returned pointer. This provides an |
sample will be visible via the returned pointer. |
138 |
interface into the data suitable for legacy C code. |
|
139 |
|
** This provides an interface into the data suitable for legacy C code. |
140 |
*/ |
*/ |
141 |
virtual |
virtual |
142 |
double* |
double* |
154 |
|
|
155 |
/** |
/** |
156 |
\brief |
\brief |
157 |
Return the tag number associated with the given data-point number. |
Return the tag number associated with the given data-point number |
158 |
|
according to the associated function space. |
159 |
*/ |
*/ |
160 |
virtual |
virtual |
161 |
int |
int |
166 |
getPointOffset |
getPointOffset |
167 |
|
|
168 |
Description: |
Description: |
169 |
Return the offset to the given data-point. This is somewhat artificial, |
Return the offset to the given data-point value in the underlying |
170 |
but returns the offset for the given point in the DataTagged object. |
data vector. |
|
Only really necessary to avoid many DataArrayView objects. |
|
171 |
|
|
172 |
\param sampleNo - Input - sample number. |
\param sampleNo - Input - sample number. |
173 |
\param dataPointNo - Input - data-point number. |
\param dataPointNo - Input - data-point number. |
260 |
Description: |
Description: |
261 |
Return a view into the data-point specified by the given sample |
Return a view into the data-point specified by the given sample |
262 |
and data-point numbers. |
and data-point numbers. |
|
NOTE: Construction of the DataArrayView is a relatively expensive |
|
|
operation. |
|
263 |
\param sampleNo - Input. |
\param sampleNo - Input. |
264 |
\param dataPointNo - Input. |
\param dataPointNo - Input. |
265 |
*/ |
*/ |
283 |
isCurrentTag |
isCurrentTag |
284 |
|
|
285 |
Description: |
Description: |
286 |
Return true if the given tag exists within the DataTagged tag keys. |
Return true if the given tag exists within the DataTagged tag map. |
287 |
NOTE: The DataTagged keys do not necessarily coincide with the tag |
|
288 |
keys for the function space. |
NOTE: The DataTagged tag map does not necessarily coincide with the tag |
289 |
|
keys in the associated function space. |
290 |
*/ |
*/ |
291 |
bool |
bool |
292 |
isCurrentTag(int tag) const; |
isCurrentTag(int tag) const; |
297 |
|
|
298 |
Description: |
Description: |
299 |
Return the default value. This value is associated with any tag which |
Return the default value. This value is associated with any tag which |
300 |
is not explicitly recorded in this DataTagged object. |
is not explicitly recorded in this DataTagged object's tag map. |
301 |
*/ |
*/ |
302 |
DataArrayView& |
DataArrayView& |
303 |
getDefaultValue(); |
getDefaultValue(); |
387 |
DataMapType m_offsetLookup; |
DataMapType m_offsetLookup; |
388 |
|
|
389 |
// |
// |
390 |
// the default value offset |
// the offset to the default value |
391 |
static const int m_defaultValueOffset = 0; |
static const int m_defaultValueOffset = 0; |
392 |
|
|
393 |
// |
// |
420 |
return getPointDataView(); |
return getPointDataView(); |
421 |
} |
} |
422 |
|
|
423 |
|
inline |
424 |
|
const DataTagged::DataMapType& |
425 |
|
DataTagged::getTagLookup() const |
426 |
|
{ |
427 |
|
return m_offsetLookup; |
428 |
|
} |
429 |
|
|
430 |
|
inline |
431 |
|
DataArrayView::ValueType::size_type |
432 |
|
DataTagged::getLength() const |
433 |
|
{ |
434 |
|
return m_data.size(); |
435 |
|
} |
436 |
|
|
437 |
} // end of namespace |
} // end of namespace |
438 |
|
|
439 |
#endif |
#endif |