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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1799 - (hide annotations)
Wed Sep 17 06:33:18 2008 UTC (11 years, 5 months ago) by jfenwick
File MIME type: text/plain
File size: 21059 byte(s)
Added Data::copySelf() [Note: this is exposed as copy() in python].
This method returns a pointer to a deep copy of the target.
There are c++ tests but no python tests for this yet.

All DataAbstracts now have a deepCopy() which simplifies the 
implementation of the compy methods.


1 jgs 121
2 ksteube 1312 /* $Id$ */
3 jgs 121
4 ksteube 1312 /*******************************************************
5     *
6     * Copyright 2003-2007 by ACceSS MNRF
7     * Copyright 2007 by University of Queensland
8     *
9     * http://esscc.uq.edu.au
10     * Primary Business: Queensland, Australia
11     * Licensed under the Open Software License version 3.0
12     * http://www.opensource.org/licenses/osl-3.0.php
13     *
14     *******************************************************/
15    
16 jgs 82 #if !defined escript_DataTagged_20040615_H
17     #define escript_DataTagged_20040615_H
18 woo409 757 #include "system_dep.h"
19 jgs 82
20 jgs 474 #include "DataAbstract.h"
21 jfenwick 1796 #include "DataTypes.h"
22 jgs 82
23     #include <vector>
24     #include <map>
25    
26     namespace escript {
27    
28     class DataConstant;
29    
30     /**
31     \brief
32 jgs 496 Simulates a full dataset accessible via sampleNo and dataPointNo.
33 jgs 82
34     Description:
35 jgs 496 Each data-point has an associated tag number, and a given tag can represent a
36     range of dataPointNo and sampleNo. Each tag indexes only a single data-point.
37 jgs 82 Thus only a single data-point needs to be stored for a range of sampleNo and
38     dataPointNo values.
39     */
40    
41     class DataTagged : public DataAbstract {
42    
43     public:
44    
45 jgs 119 //
46 jgs 496 // Types for the lists of tags and values.
47 jgs 121 typedef std::vector<int> TagListType;
48 jfenwick 1796 // typedef std::vector<DataArrayView> ValueListType;
49     typedef DataTypes::ValueType ValueType;
50     typedef std::vector<ValueType::ElementType> ValueBatchType;
51 jgs 82
52     //
53 jgs 496 // Map from a tag to an offset into the data array.
54 jgs 82 typedef std::map<int, int> DataMapType;
55    
56     /**
57     \brief
58     Default constructor for DataTagged.
59    
60     Description:
61     Default constructor for DataTagged. Creates a DataTagged object for which
62 jgs 509 the default data-point is a scalar data-point with value 0.0, and no other
63     tag values are stored.
64 jgs 507 T
65 jgs 82 */
66 woo409 757 ESCRIPT_DLL_API
67 jgs 82 DataTagged();
68    
69 jfenwick 1796 // /**
70     // \brief
71     // Constructor for DataTagged.
72     //
73     // Description:
74     // Constructor for DataTagged.
75     // \param tagKeys - Input - A vector of integer tags.
76     // \param values - Input - A vector of DataArrayViews. If this is empty
77     // all tag values will be assigned a scalar data-point of value
78     // 0. If it contains one value all tag values will be assigned
79     // this value. Otherwise consecutive tags will be assigned
80     // consecutive values. If there is a mismatch between the
81     // number of keys and the number of values an exception
82     // will be generated.
83     // \param defaultValue - Input - Value returned if a requested tag doesn't exist.
84     // \param what - Input - A description of what this data represents.
85     // T
86     // */
87     // ESCRIPT_DLL_API
88     // DataTagged(const TagListType& tagKeys,
89     // const ValueListType& values,
90     // const DataArrayView& defaultValue,
91     // const FunctionSpace& what);
92 jgs 82
93     /**
94     \brief
95 jgs 496 Alternative Constructor for DataTagged.
96 jgs 119
97     Description:
98 jgs 496 Alternative Constructor for DataTagged.
99 jgs 119 \param what - Input - A description of what this data object represents.
100 jgs 496 \param shape - Input - The shape of each data-point.
101 jfenwick 1796 \param tags - Input - An array of tags, one for each sample number (starts at tag[1]).
102 jgs 496 \param data - The data values for each tag.
103 jgs 535 NB: no unit testing yet
104 jgs 119 */
105 woo409 757 ESCRIPT_DLL_API
106 jgs 119 DataTagged(const FunctionSpace& what,
107 jfenwick 1796 const DataTypes::ShapeType &shape,
108 jgs 119 const int tags[],
109 jgs 500 const ValueType& data);
110 jgs 119
111 jfenwick 1796 /**
112 jgs 119 \brief
113 woo409 757 Alternative Constructor for DataTagged.
114    
115     Description:
116     Alternative Constructor for DataTagged.
117     \param what - Input - A description of what this data object represents.
118     \param shape - Input - The shape of each data-point.
119     \param tags - Input - An vector of tags, one for each sample number.
120     \param data - The data values for each tag.
121 jfenwick 1796 TODO Make sure to document the relationship between tags and data, ie: data also contains the default value
122     */
123 woo409 757 ESCRIPT_DLL_API
124     DataTagged(const FunctionSpace& what,
125 jfenwick 1796 const DataTypes::ShapeType &shape,
126 woo409 757 const TagListType& tags,
127     const ValueType& data);
128    
129     /**
130     \brief
131 jgs 496 Copy Constructor for DataTagged.
132 jgs 82 Performs a deep copy from the given DataTagged object.
133 jgs 507 T
134 jgs 82 */
135 woo409 757 ESCRIPT_DLL_API
136 jgs 82 DataTagged(const DataTagged& other);
137    
138     /**
139     \brief
140 jgs 496 Copy Constructor for DataTagged.
141 jgs 509 Construct a DataTagged object from a DataConstant object.
142     The default value will be the value of the DataConstant object.
143 jgs 507 T
144 jgs 82 */
145 woo409 757 ESCRIPT_DLL_API
146 jgs 82 DataTagged(const DataConstant& other);
147    
148     /**
149     \brief
150 jfenwick 1796 Copies the tags from a DataTagged into a new Data Tagged and assigns them the default value. ** Not unit tested **
151    
152     This is different from a deep copy because we are not copying shape or other information, just tags.
153     \param what - Input - FunctionSpace for the new DataTagged
154     \param shape - Input - Shape for points in the new DataTagged
155     \param defaultvalue - Input - Default value for new DataTagged
156     \param tagsource - Input - A DataTagged object which supplies the tags.
157     */
158     ESCRIPT_DLL_API
159     DataTagged(const FunctionSpace& what,
160     const DataTypes::ShapeType& shape,
161     const DataTypes::ValueType& defaultvalue,
162     const DataTagged* tagsource=0);
163    
164     /**
165     \brief
166 phornby 1628 Destructor
167     */
168     ESCRIPT_DLL_API
169     inline virtual
170     ~DataTagged() {};
171    
172     /**
173 jfenwick 1799 \brief Return a deep copy of the current object.
174     */
175     ESCRIPT_DLL_API
176     virtual
177     DataAbstract*
178     deepCopy();
179    
180    
181     /**
182 phornby 1628 \brief
183 jgs 82 getSampleDataByTag
184    
185     Description:
186 jgs 496 Return the data-point for the given tag. All of the data for the
187     sample will be visible via the returned pointer.
188    
189     ** This provides an interface into the data suitable for legacy C code.
190 jgs 507 ** NB: need to do array bounds checking when accessing returned value!
191     T
192 jgs 82 */
193 woo409 757 ESCRIPT_DLL_API
194 jgs 82 virtual
195     double*
196     getSampleDataByTag(int tag);
197    
198     /**
199     \brief
200     Write the data as a string.
201     Writes out each tag, including the default, and the data-point which is
202     associated with each tag.
203 jgs 507 T
204 jgs 82 */
205 woo409 757 ESCRIPT_DLL_API
206 jgs 82 virtual
207     std::string
208     toString() const;
209 gross 950 /**
210     \brief
211     dumps the object into a netCDF file
212     */
213     ESCRIPT_DLL_API
214     virtual
215     void
216     dump(const std::string fileName) const;
217 jgs 82
218 gross 1118 /**
219     \brief
220     sets all values to zero
221     */
222     ESCRIPT_DLL_API
223     virtual
224     void
225     setToZero();
226    
227 jgs 82 /**
228     \brief
229 jgs 496 Return the tag number associated with the given data-point number
230     according to the associated function space.
231 jgs 507 T
232 jgs 149 */
233 woo409 757 ESCRIPT_DLL_API
234 jgs 149 virtual
235     int
236     getTagNumber(int dpno);
237    
238     /**
239     \brief
240 jgs 82 getPointOffset
241    
242     Description:
243 jgs 496 Return the offset to the given data-point value in the underlying
244     data vector.
245 jgs 82
246     \param sampleNo - Input - sample number.
247     \param dataPointNo - Input - data-point number.
248 jgs 507 T
249     */
250 woo409 757 ESCRIPT_DLL_API
251 jgs 82 virtual
252 jgs 121 ValueType::size_type
253 jgs 82 getPointOffset(int sampleNo,
254     int dataPointNo) const;
255    
256 jfenwick 1796
257    
258     // /**
259     // \brief
260     // addTaggedValues
261     //
262     // Description:
263     // Add the given tags and values to this DataTagged object.
264     // \param tagKeys - Input - A vector of integer tags.
265     // \param values - Input - A vector of DataArrayViews. If this is empty
266     // all tag values will be assigned a scalar data-point of value
267     // 0. If it contains one value all tag values will be assigned
268     // this value. Otherwise consecutive tags will be assigned
269     // consecutive values. If there is a mismatch between the
270     // number of keys and the number of values an exception
271     // will be generated.
272     // T
273     // */
274     // ESCRIPT_DLL_API
275     // void
276     // addTaggedValues(const TagListType& tagKeys,
277     // const ValueListType& values);
278    
279     // /**
280     // \brief
281     // addTaggedValue
282     //
283     // Description:
284     // Add a single tag and value to this DataTagged object. If this tag already has
285     // a value associated with it, setTaggedValue will be used to update this value.
286     // \param tagKey - Input - Integer tag.
287     // \param value - Input - Single DataArrayView value to be assigned to the tag.
288     // T
289     // */
290     // ESCRIPT_DLL_API
291     // void
292     // addTaggedValue(int tagKey,
293     // const DataArrayView& value);
294    
295    
296    
297     /**
298 jgs 82 \brief
299     addTaggedValues
300    
301     Description:
302 jgs 509 Add the given tags and values to this DataTagged object.
303 jgs 507 \param tagKeys - Input - A vector of integer tags.
304 jfenwick 1796 \param values - Input - A vector of doubles. If this is empty, the default value for
305     this DataTagged will be used for all tags.
306     If it contains one value all tag values will be assigned
307 jgs 509 this value. Otherwise consecutive tags will be assigned
308     consecutive values. If there is a mismatch between the
309     number of keys and the number of values an exception
310     will be generated.
311 jfenwick 1796 \param vShape - shape of the datapoints in "values"
312 jgs 507 T
313 jfenwick 1796 */
314     ESCRIPT_DLL_API
315     void
316     addTaggedValues(const TagListType& tagKeys,
317     const ValueBatchType& values,
318     const ShapeType& vShape);
319    
320    
321     /**
322     Description:
323     Add the given tags and values to this DataTagged object.
324     \param tagKeys - Input - A vector of integer tags.
325     \param values - Input - A DataVector containing the datapoints.
326     If this is empty, the default value for
327     this DataTagged will be used for all tags.
328     If it contains one value all tag values will be assigned
329     this value. Otherwise consecutive tags will be assigned
330     consecutive values. If there is a mismatch between the
331     number of keys and the number of values an exception
332     will be generated.
333     \param vShape - shape of the datapoints in "values"
334    
335     TODO Makesure this is properly unit tested
336 jgs 82 */
337 woo409 757 ESCRIPT_DLL_API
338 jgs 82 void
339     addTaggedValues(const TagListType& tagKeys,
340 jfenwick 1796 const ValueType& values,
341     const ShapeType& vShape);
342 jgs 82
343 jfenwick 1796
344    
345    
346 jgs 82 /**
347     \brief
348     addTaggedValue
349    
350     Description:
351 jgs 121 Add a single tag and value to this DataTagged object. If this tag already has
352     a value associated with it, setTaggedValue will be used to update this value.
353 jgs 509 \param tagKey - Input - Integer tag.
354 jfenwick 1796 \param pointshape - Shape of the value parameter
355     \param value - Input - Single DataArrayView value to be assigned to the tag.
356     \param dataOffset - Input - Offset of the beginning of the point in the value parameter
357 jgs 82 */
358 woo409 757 ESCRIPT_DLL_API
359 jgs 82 void
360     addTaggedValue(int tagKey,
361 jfenwick 1796 const DataTypes::ShapeType& pointshape,
362     const ValueType& value,
363     int dataOffset=0);
364 jgs 82
365     /**
366     \brief
367 jfenwick 1796 addTag - does not modify the default value for this object. ** Not unit tested **
368 jgs 82
369     Description:
370 jfenwick 1796 Add a single tag. The default value for this DataTagged will be associated with the tag.
371     If this tag already has a value associated with it, then no change will be made.
372     \param tagKey - Input - Integer tag.
373     TODO: Make sure this is unit tested
374 jgs 82 */
375 woo409 757 ESCRIPT_DLL_API
376 jgs 82 void
377 jfenwick 1796 addTag(int tagKey);
378 jgs 82
379 jfenwick 1796
380     // /**
381     // \brief
382     // setTaggedValues
383     //
384     // Description:
385     // Set the given tags to the given values in this DataTagged object.
386     // \param tagKeys - Input - A vector of integer tag.
387     // \param values - Input - A vector of DataArrayViews. If this is empty
388     // all tag values will be assigned a scalar data-point of value
389     // 0. If it contains one value all tag values will be assigned
390     // this value. Otherwise consecutive tags will be assigned
391     // consecutive values. If there is a mismatch between the
392     // number of keys and the number of values an exception
393     // will be generated.
394     // T
395     // */
396     // ESCRIPT_DLL_API
397     // void
398     // setTaggedValues(const TagListType& tagKeys,
399     // const ValueListType& values);
400    
401     // /**
402     // \brief
403     // setTaggedValue
404     //
405     // Description:
406     // Assign the given value to the given tag.
407     // \param tagKey - Input - Integer tag.
408     // \param value - Input - Single DataArrayView value to be assigned to the tag.
409     // T
410     // */
411     // ESCRIPT_DLL_API
412     // virtual
413     // void
414     // setTaggedValue(int tagKey,
415     // const DataArrayView& value);
416    
417 jgs 82 /**
418     \brief
419     setTaggedValue
420    
421     Description:
422 jgs 509 Assign the given value to the given tag.
423     \param tagKey - Input - Integer tag.
424 jfenwick 1796 \param pointshape - the shape of the value parameter
425     \param value - Input - Vector storing the datapoint to be assigned to the tag.
426     \param dataOffset - beginning of the datapoint within "value".
427 jgs 507 T
428 jgs 82 */
429 woo409 757 ESCRIPT_DLL_API
430 jgs 82 void
431     setTaggedValue(int tagKey,
432 jfenwick 1796 const DataTypes::ShapeType& pointshape,
433     const ValueType& value,
434     int dataOffset=0);
435 jgs 82
436 jfenwick 1796
437     // /**
438     // \brief
439     // getDataPointByTag
440     //
441     // Description:
442     // Return data-point associated with the given tag as a DataArrayView.
443     // \param tag - Input - Integer key.
444     // T
445     // */
446     // ESCRIPT_DLL_API
447     // DataArrayView
448     // getDataPointByTag(int tag) const;
449    
450 jgs 82 /**
451     \brief
452 jfenwick 1796 getDataByTag
453 jgs 82
454 jfenwick 1796 Return a pointer to the beginning of the datapoint with the specified tag.
455     TODO Eventually these should be inlined.
456 jgs 82 \param tag - Input - Integer key.
457 jfenwick 1796 \param i - position in the underlying datastructure
458 jgs 507 T
459 jgs 82 */
460 woo409 757 ESCRIPT_DLL_API
461 jfenwick 1796 DataTypes::ValueType::const_reference
462     getDataByTag(int tag, DataTypes::ValueType::size_type i) const;
463 jgs 82
464 jfenwick 1796 ESCRIPT_DLL_API
465     DataTypes::ValueType::reference
466     getDataByTag(int tag, DataTypes::ValueType::size_type i);
467    
468    
469 jgs 82 /**
470 jfenwick 1796 \brief
471     getOffsetForTag
472 jgs 82
473 jfenwick 1796 \param tag
474     \return the offset of the beginning of the datapoint corresponding to tag.
475    
476     Note: If the tag is not valid, the offset of the default value is returned instead.
477 jgs 82 */
478 woo409 757 ESCRIPT_DLL_API
479 jfenwick 1796 DataTypes::ValueType::size_type
480     getOffsetForTag(int tag) const;
481 jgs 82
482 jfenwick 1796 // /**
483     // \brief
484     // getDataPoint
485     //
486     // Description:
487     // Return the data-point specified by the given sample and data-point
488     // numbers as a DataArrayView.
489     // \param sampleNo - Input.
490     // \param dataPointNo - Input.
491     // T
492     // */
493     // ESCRIPT_DLL_API
494     // virtual
495     // DataArrayView
496     // getDataPoint(int sampleNo,
497     // int dataPointNo);
498    
499    
500 jgs 82 /**
501 gross 983 \brief
502 jfenwick 1796 Return a reference to the underlying DataVector.
503     */
504    
505     ESCRIPT_DLL_API
506     DataTypes::ValueType&
507     getVector();
508    
509     ESCRIPT_DLL_API
510     const DataTypes::ValueType&
511     getVector() const;
512    
513    
514    
515     /**
516     \brief
517 gross 983 getData
518    
519     Description:
520     Return pointer to the data
521     T
522     */
523 jfenwick 1796 // ESCRIPT_DLL_API
524     // const DataTypes::ValueType::ElementType*
525     // getData() const;
526 gross 983
527     /**
528 jgs 82 \brief
529     getTagLookup
530    
531     Description:
532     Return a reference to the tag offset lookup table.
533 jgs 507 T
534 jgs 82 */
535 woo409 757 ESCRIPT_DLL_API
536 jgs 82 const DataMapType&
537     getTagLookup() const;
538    
539     /**
540     \brief
541     isCurrentTag
542    
543     Description:
544 jgs 496 Return true if the given tag exists within the DataTagged tag map.
545    
546 jgs 509 *** NB: The DataTagged tag map does not necessarily coincide with the tag
547 jgs 496 keys in the associated function space.
548 jgs 507 T
549     */
550 woo409 757 ESCRIPT_DLL_API
551 jgs 82 bool
552     isCurrentTag(int tag) const;
553    
554 jfenwick 1796 // /**
555     // \brief
556     // getDefaultValue
557     //
558     // Description:
559     // Return the default value. This value is associated with any tag which
560     // is not explicitly recorded in this DataTagged object's tag map.
561     // T
562     // */
563     // ESCRIPT_DLL_API
564     // DataArrayView&
565     // getDefaultValue();
566     //
567     // ESCRIPT_DLL_API
568     // const DataArrayView&
569     // getDefaultValue() const;
570    
571 jgs 82 /**
572     \brief
573     getDefaultValue
574    
575     Description:
576     Return the default value. This value is associated with any tag which
577 jgs 496 is not explicitly recorded in this DataTagged object's tag map.
578 jfenwick 1796 \param i - position in the underlying datastructure
579 jgs 507 T
580 jgs 82 */
581 woo409 757 ESCRIPT_DLL_API
582 jfenwick 1796 DataTypes::ValueType::reference
583     getDefaultValue(DataTypes::ValueType::size_type i);
584 jgs 82
585 woo409 757 ESCRIPT_DLL_API
586 jfenwick 1796 DataTypes::ValueType::const_reference
587     getDefaultValue(DataTypes::ValueType::size_type i) const;
588 jgs 82
589 jfenwick 1796
590    
591    
592 jgs 82 /**
593     \brief
594     getLength
595    
596     Description:
597 jgs 509 Return the total number of doubles stored for this DataTagged object.
598 jgs 507 T
599 jgs 82 */
600 woo409 757 ESCRIPT_DLL_API
601 jgs 82 virtual
602     ValueType::size_type
603     getLength() const;
604    
605     /**
606     \brief
607     getSlice
608    
609     Description:
610 jgs 513 Factory method that returns a newly created DataTagged object generated
611     by taking the specified slice from this DataTagged object.
612     The caller is reponsible for managing the returned object.
613 jgs 535 T
614 jgs 82 */
615 woo409 757 ESCRIPT_DLL_API
616 jgs 82 virtual
617     DataAbstract*
618 jfenwick 1796 getSlice(const DataTypes::RegionType& region) const;
619 jgs 82
620     /**
621     \brief
622 jgs 513 Slice Constructor for DataTagged.
623 jgs 82
624     Description:
625 jgs 513 Creates a DataTagged object which is the specified slice
626 jgs 519 from the given DataTagged object.
627     \param other - Input - DataTagged object to slice from.
628     \param region - Input - Region to slice.
629 jgs 535 T
630 jgs 82 */
631 woo409 757 ESCRIPT_DLL_API
632 jgs 513 DataTagged(const DataTagged& other,
633 jfenwick 1796 const DataTypes::RegionType& region);
634 jgs 513
635     /**
636     \brief
637     setSlice
638    
639     Description:
640 jgs 519 Copy the given Data object into the specified region in this object.
641 jgs 513 \param other - Input - Data object to copy from.
642 jgs 519 \param region - Input - Region to copy into (NB: must have same shape as other!).
643 jgs 535 T
644 jgs 513 */
645 woo409 757 ESCRIPT_DLL_API
646 jgs 82 virtual
647     void
648 jgs 513 setSlice(const DataAbstract* other,
649 jfenwick 1796 const DataTypes::RegionType& region);
650 jgs 82
651 jgs 123
652     /**
653 jgs 509 \brief
654 ksteube 775 Computes a symmetric matrix (A + AT) / 2
655    
656     \param ev - Output - symmetric matrix
657    
658     */
659 gross 800 ESCRIPT_DLL_API
660 ksteube 775 virtual void
661     symmetric(DataAbstract* ev);
662    
663     /**
664     \brief
665     Computes a nonsymmetric matrix (A - AT) / 2
666    
667     \param ev - Output - nonsymmetric matrix
668    
669     */
670 gross 800 ESCRIPT_DLL_API
671 ksteube 775 virtual void
672     nonsymmetric(DataAbstract* ev);
673    
674     /**
675     \brief
676     Computes the trace of a matrix
677    
678     \param ev - Output - the trace of a matrix
679    
680     */
681 gross 800 ESCRIPT_DLL_API
682 ksteube 775 virtual void
683 gross 800 trace(DataAbstract* ev, int axis_offset);
684 ksteube 775
685     /**
686     \brief
687 gross 804 swaps components axis0 and axis1
688 gross 800
689     \param ev - Output - swapped components
690    
691     */
692     ESCRIPT_DLL_API
693     virtual void
694 gross 804 swapaxes(DataAbstract* ev, int axis0, int axis1);
695 gross 800
696     /**
697     \brief
698 ksteube 775 Transpose each data point of this Data object around the given axis.
699    
700     \param ev - Output - the transpose of a matrix
701    
702     */
703 gross 800 ESCRIPT_DLL_API
704 ksteube 775 virtual void
705     transpose(DataAbstract* ev, int axis_offset);
706    
707     /**
708     \brief
709 gross 580 solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
710    
711     \param ev - Output - eigenvalues in increasing order at each data point
712    
713     */
714 woo409 757 ESCRIPT_DLL_API
715 gross 580 virtual void
716     eigenvalues(DataAbstract* ev);
717    
718     /**
719     \brief
720     solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
721    
722     \param ev - Output - eigenvalues in increasing order at each data point
723     \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
724     and the first nonzero component is positive.
725     \param tol - Input - eigenvalue with relative distance tol are treated as equal.
726    
727     */
728    
729 woo409 757 ESCRIPT_DLL_API
730 gross 580 virtual void
731     eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
732    
733    
734 jfenwick 1796 /**
735     \brief Returns the offset in the structure which stores the default value
736     */
737     ESCRIPT_DLL_API
738     DataTypes::ValueType::size_type
739     getDefaultOffset() const;
740    
741 jgs 82 protected:
742    
743     private:
744    
745     //
746     // The offset lookup table
747     DataMapType m_offsetLookup;
748    
749     //
750 jgs 496 // the offset to the default value
751 jgs 119 static const int m_defaultValueOffset = 0;
752    
753     //
754 jgs 82 // The actual data
755 jgs 121 ValueType m_data;
756 jgs 82
757     };
758    
759     inline
760     bool
761     DataTagged::isCurrentTag(int tag) const
762     {
763     DataMapType::const_iterator pos(m_offsetLookup.find(tag));
764     return (pos!=m_offsetLookup.end());
765     }
766    
767 jfenwick 1796 // inline
768     // DataArrayView&
769     // DataTagged::getDefaultValue()
770     // {
771     // // The default value is always the first value.
772     // return getPointDataView();
773     // }
774    
775     // inline
776     // const DataArrayView&
777     // DataTagged::getDefaultValue() const
778     // {
779     // // The default value is always the first value.
780     // return getPointDataView();
781     // }
782    
783    
784     inline
785     DataTypes::ValueType::size_type
786     DataTagged::getDefaultOffset() const
787 jgs 82 {
788 jfenwick 1796 return m_defaultValueOffset;
789 jgs 82 }
790    
791     inline
792 jfenwick 1796 DataTypes::ValueType::reference
793     DataTagged::getDefaultValue(DataTypes::ValueType::size_type i)
794 jgs 82 {
795 jfenwick 1796 return getVector()[i];
796 jgs 82 }
797    
798 jgs 496 inline
799 jfenwick 1796 DataTypes::ValueType::const_reference
800     DataTagged::getDefaultValue(DataTypes::ValueType::size_type i) const
801 gross 983 {
802 jfenwick 1796 return getVector()[i];
803 gross 983 }
804    
805 jfenwick 1796
806    
807    
808     // inline
809     // const DataTypes::ValueType::ElementType*
810     // DataTagged::getData() const
811     // {
812     // return &(m_data[0]);
813     // }
814    
815 gross 983 inline
816 jgs 496 const DataTagged::DataMapType&
817     DataTagged::getTagLookup() const
818     {
819     return m_offsetLookup;
820     }
821    
822     inline
823 jfenwick 1796 DataTypes::ValueType::size_type
824 jgs 496 DataTagged::getLength() const
825     {
826     return m_data.size();
827     }
828    
829 jgs 82 } // end of namespace
830    
831     #endif

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26