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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 120 by jgs, Tue Apr 12 04:45:05 2005 UTC revision 121 by jgs, Fri May 6 04:26:16 2005 UTC
# Line 1  Line 1 
1  // $Id$  // $Id$
2  /*  
3    /*
4   ******************************************************************************   ******************************************************************************
5   *                                                                            *   *                                                                            *
6   *       COPYRIGHT  ACcESS 2004 -  All Rights Reserved                        *   *       COPYRIGHT  ACcESS 2004 -  All Rights Reserved                        *
# Line 12  Line 13 
13   *                                                                            *   *                                                                            *
14   ******************************************************************************   ******************************************************************************
15  */  */
16                                                                              
17  #if !defined escript_DataTagged_20040615_H  #if !defined escript_DataTagged_20040615_H
18  #define escript_DataTagged_20040615_H  #define escript_DataTagged_20040615_H
19    
# Line 46  class DataTagged : public DataAbstract { Line 47  class DataTagged : public DataAbstract {
47    
48    //    //
49    // Types for the lists of tags and values    // Types for the lists of tags and values
50    typedef std::vector<int> TagListType;    typedef std::vector<int>           TagListType;
51    typedef std::vector<DataArrayView> ValueListType;    typedef std::vector<DataArrayView> ValueListType;
52      typedef DataArrayView::ValueType   ValueType;
53    
54    //    //
55    // Map from the tag to an offset the the data array.    // Map from the tag to an offset the the data array.
# Line 99  class DataTagged : public DataAbstract { Line 101  class DataTagged : public DataAbstract {
101    DataTagged(const FunctionSpace& what,    DataTagged(const FunctionSpace& what,
102               const DataArrayView::ShapeType &shape,               const DataArrayView::ShapeType &shape,
103               const int tags[],               const int tags[],
104               const DataArrayView::ValueType &data);               const ValueType &data);
105    
106    /**    /**
107       \brief       \brief
# Line 164  class DataTagged : public DataAbstract { Line 166  class DataTagged : public DataAbstract {
166       \param dataPointNo - Input - data-point number.       \param dataPointNo - Input - data-point number.
167     */     */
168    virtual    virtual
169    DataArrayView::ValueType::size_type    ValueType::size_type
170    getPointOffset(int sampleNo,    getPointOffset(int sampleNo,
171                   int dataPointNo) const;                   int dataPointNo) const;
172    
# Line 173  class DataTagged : public DataAbstract { Line 175  class DataTagged : public DataAbstract {
175       addTaggedValues       addTaggedValues
176    
177       Description:       Description:
178       Add the given tags and values to this DataTagged object.       Add the given tags and values to this DataTagged object, by repeatedly
179         using addTaggedValue for each given tag/value pair.
180       \param tagKeys - Input - A vector of integer keys.       \param tagKeys - Input - A vector of integer keys.
181       \param values - Input - A vector of DataArrayViews. If this is empty       \param values - Input - A vector of DataArrayViews. If this is empty
182                     then all given tags will be assigned a value of zero. If                        then all given tags will be assigned a value of zero. If
183                     it contains one value all tags will be assigned the same value.                        it contains one value all tags will be assigned the same value.
184                     Otherwise if there is a mismatch between the number of tags and                        Otherwise if there is a mismatch between the number of tags and
185                     the number of values an exception will be generated.                        the number of values an exception will be generated.
      NB: If a tag given here already exists in this object, this attempt to add the given  
      value will have no effect. setTaggedValues is more versatile and should be  
      used in most cases in preference to addTaggedValues.  
186    */    */
187    void    void
188    addTaggedValues(const TagListType& tagKeys,    addTaggedValues(const TagListType& tagKeys,
# Line 193  class DataTagged : public DataAbstract { Line 193  class DataTagged : public DataAbstract {
193       addTaggedValue       addTaggedValue
194    
195       Description:       Description:
196       Add a single tag and value to this DataTagged object.       Add a single tag and value to this DataTagged object. If this tag already has
197         a value associated with it, setTaggedValue will be used to update this value.
198       \param tagKey - Input - Integer key.       \param tagKey - Input - Integer key.
199       \param value - Input - DataArrayView.       \param value - Input - Single DataArrayView value to be assigned to the tag.
      NB: If this tag already exists in this object, this attempt to add the given  
      value will have no effect. setTaggedValue is more versatile and should be  
      used in most cases in preference to addTaggedValue.  
200    */    */
201    void    void
202    addTaggedValue(int tagKey,    addTaggedValue(int tagKey,
# Line 209  class DataTagged : public DataAbstract { Line 207  class DataTagged : public DataAbstract {
207       setTaggedValues       setTaggedValues
208    
209       Description:       Description:
210       Assign the given values to the tags listed.       Set the given tags to the given values in this DataTagged object, by repeatedly
211         using setTaggedValue for each given tag/value pair.
212       \param tagKeys - Input - A vector of integer keys.       \param tagKeys - Input - A vector of integer keys.
213       \param values - Input - A vector of DataArrayViews. If this is empty       \param values - Input - A vector of DataArrayViews. If this is empty
214                        then all given tags will be assigned a value of zero. If                        then all given tags will be assigned a value of zero. If
215                        it contains one value all tag values will be assigned the same value.                        it contains one value all tag values will be assigned the same value.
216                        Otherwise if there is a mismatch between the number of keys and                        Otherwise if there is a mismatch between the number of keys and
217                        the number of values an exception will be generated.                        the number of values an exception will be generated.
      NB: If a given tag does not yet exist in this DataTagged object, it will be added.  
218    */    */
219    void    void
220    setTaggedValues(const TagListType& tagKeys,    setTaggedValues(const TagListType& tagKeys,
# Line 227  class DataTagged : public DataAbstract { Line 225  class DataTagged : public DataAbstract {
225       setTaggedValue       setTaggedValue
226    
227       Description:       Description:
228       Assign the given value to the given tag.       Assign the given value to the given tag. If this tag does not already have a value
229         associated with it, addTaggedValue will be used to add this tag/value pair.
230       \param tagKey - Input - Integer key.       \param tagKey - Input - Integer key.
231       \param value - Input - Single DataArrayView value to be assigned to the tag.       \param value - Input - Single DataArrayView value to be assigned to the tag.
      NB: If the given tag does not yet exist in this DataTagged object, it will be added.  
232    */    */
233    virtual    virtual
234    void    void
# Line 365  class DataTagged : public DataAbstract { Line 363  class DataTagged : public DataAbstract {
363    
364    //    //
365    // The actual data    // The actual data
366    DataArrayView::ValueType m_data;    ValueType m_data;
367    
368  };  };
369    
# Line 381  inline Line 379  inline
379  DataArrayView&  DataArrayView&
380  DataTagged::getDefaultValue()  DataTagged::getDefaultValue()
381  {  {
   //  
382    // The default value is always the first value.    // The default value is always the first value.
383    return getPointDataView();    return getPointDataView();
384  }  }
# Line 390  inline Line 387  inline
387  const DataArrayView&  const DataArrayView&
388  DataTagged::getDefaultValue() const  DataTagged::getDefaultValue() const
389  {  {
   //  
390    // The default value is always the first value.    // The default value is always the first value.
391    return getPointDataView();    return getPointDataView();
392  }  }

Legend:
Removed from v.120  
changed lines
  Added in v.121

  ViewVC Help
Powered by ViewVC 1.1.26