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

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

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

revision 1795 by gross, Thu Apr 10 05:28:01 2008 UTC revision 1796 by jfenwick, Wed Sep 17 01:45:46 2008 UTC
# Line 16  Line 16 
16  #define escript_DataAbstract_20040315_H  #define escript_DataAbstract_20040315_H
17  #include "system_dep.h"  #include "system_dep.h"
18    
19  #include "DataArrayView.h"  #include "DataTypes.h"
20  #include "FunctionSpace.h"  #include "FunctionSpace.h"
21    
22  #include <boost/scoped_ptr.hpp>  #include <boost/scoped_ptr.hpp>
# Line 45  class DataAbstract { Line 45  class DataAbstract {
45    
46   public:   public:
47    
48    typedef DataArrayView::ValueType ValueType;    typedef DataTypes::ValueType ValueType;
49    typedef DataArrayView::ShapeType ShapeType;    typedef DataTypes::ShapeType ShapeType;
50    
51    /**    /**
52       \brief       \brief
# Line 58  class DataAbstract { Line 58  class DataAbstract {
58       \param what - Input - A description of what this data represents.       \param what - Input - A description of what this data represents.
59    */    */
60    ESCRIPT_DLL_API    ESCRIPT_DLL_API
61    DataAbstract(const FunctionSpace& what);    DataAbstract(const FunctionSpace& what, const ShapeType& shape);
62    
63    /**    /**
64      \brief      \brief
# Line 102  class DataAbstract { Line 102  class DataAbstract {
102    int    int
103    getNumSamples() const;    getNumSamples() const;
104    
105    //  /**
106    //      \brief
107    //      Return the DataArrayView of the point data. This essentially contains
108    //      the shape information for each data point although it also may be used
109    //      to manipulate the point data.
110    //  */
111    //   ESCRIPT_DLL_API
112    //   DataArrayView&
113    //   getPointDataView();
114    
115    //   ESCRIPT_DLL_API
116    //   const DataArrayView&
117    //   getPointDataView() const;
118    
119    /**    /**
120       \brief       \brief
121       Return the DataArrayView of the point data. This essentially contains       Return the shape information for the point data.
122       the shape information for each data point although it also may be used  
123       to manipulate the point data.       The omission of a non-constant form is deliberate.
124    */    */
125    ESCRIPT_DLL_API    ESCRIPT_DLL_API
126    DataArrayView&    const DataTypes::ShapeType&
127    getPointDataView();    getShape() const;
128    
129      /**
130         \brief
131         Return the rank information for the point data.
132      */
133    ESCRIPT_DLL_API    ESCRIPT_DLL_API
134    const DataArrayView&    int
135    getPointDataView() const;    getRank() const;
136    
137    
138    
139    /**    /**
140       \brief       \brief
# Line 131  class DataAbstract { Line 151  class DataAbstract {
151    getPointOffset(int sampleNo,    getPointOffset(int sampleNo,
152                   int dataPointNo) const = 0;                   int dataPointNo) const = 0;
153    
154    //  /**
155    //  return the container storing points for this object
156    //  */
157    //   ESCRIPT_DLL_API
158    //   virtual
159    //   ValueType&
160    //   getVector();
161    //
162    //   ESCRIPT_DLL_API
163    //   virtual
164    //   const ValueType&
165    //   getVector() const;
166    
167    
168    /**    /**
169       \brief       \brief
170       Return the sample data for the given sample number.       Return the sample data for the given sample number.
# Line 186  class DataAbstract { Line 220  class DataAbstract {
220    bool    bool
221    validSampleNo(int sampleNo) const;    validSampleNo(int sampleNo) const;
222    
223    /**  //  /**
224       \brief  //      \brief
225       Return a view into the data for the data point specified.  //      Return a view into the data for the data point specified.
226       NOTE: Construction of the DataArrayView is a relatively expensive  //      NOTE: Construction of the DataArrayView is a relatively expensive
227       operation.  //      operation.
228    //
229       \param sampleNo - Input - the sample number.  //      \param sampleNo - Input - the sample number.
230       \param dataPointNo - Input - the data point number.  //      \param dataPointNo - Input - the data point number.
231    */  //  */
232    ESCRIPT_DLL_API  //   ESCRIPT_DLL_API
233    virtual  //   virtual
234    DataArrayView  //   DataArrayView
235    getDataPoint(int sampleNo,  //   getDataPoint(int sampleNo,
236                 int dataPointNo) = 0;  //                int dataPointNo) = 0;
237    
238    /**    /**
239       \brief       \brief
# Line 219  class DataAbstract { Line 253  class DataAbstract {
253    ESCRIPT_DLL_API    ESCRIPT_DLL_API
254    virtual    virtual
255    DataAbstract*    DataAbstract*
256    getSlice(const DataArrayView::RegionType& region) const = 0;    getSlice(const DataTypes::RegionType& region) const = 0;
257    
258    /**    /**
259       \brief       \brief
# Line 232  class DataAbstract { Line 266  class DataAbstract {
266    virtual    virtual
267    void    void
268    setSlice(const DataAbstract* value,    setSlice(const DataAbstract* value,
269             const DataArrayView::RegionType& region) = 0;             const DataTypes::RegionType& region) = 0;
270    
271    
272    //  /**
273    //      \brief
274    //      setTaggedValue
275    //
276    //      Description:
277    //      Assign the given value to the given tag.
278    //
279    //      NB: If the data isn't tagged an exception will be thrown.
280    //
281    //      \param tagKey - Input - Integer key.
282    //      \param value - Input - Single DataArrayView value to be assigned to the tag.
283    //  */
284    //   ESCRIPT_DLL_API
285    //   virtual
286    //   void
287    //   setTaggedValue(int tagKey,
288    //                  const DataArrayView& value);
289    
290    
291    /**    /**
# Line 245  class DataAbstract { Line 298  class DataAbstract {
298       NB: If the data isn't tagged an exception will be thrown.       NB: If the data isn't tagged an exception will be thrown.
299    
300       \param tagKey - Input - Integer key.       \param tagKey - Input - Integer key.
301       \param value - Input - Single DataArrayView value to be assigned to the tag.       \param pointshape - Input - the shape of the value parameter.
302         \param value - Input -
303    */    */
304    ESCRIPT_DLL_API    ESCRIPT_DLL_API
305    virtual    virtual
306    void    void
307    setTaggedValue(int tagKey,    setTaggedValue(int tagKey,
308                   const DataArrayView& value);           const DataTypes::ShapeType& pointshape,
309                     const DataTypes::ValueType& value,
310    /**           int dataOffset=0);
     \brief  
     Archive the underlying data values to the file referenced  
     by ofstream. A count of the number of values expected to be written  
     is provided as a cross-check.  
311    
     The return value indicates success (0) or otherwise (1).  
   */  
   ESCRIPT_DLL_API  
   virtual  
   int  
   archiveData(std::ofstream& archiveFile,  
               const ValueType::size_type noValues) const;  
312    
   /**  
     \brief  
     Extract the number of values specified by noValues from the file  
     referenced by ifstream to the underlying data structure.  
313    
     The return value indicates success (0) or otherwise (1).  
   */  
   ESCRIPT_DLL_API  
   virtual  
   int  
   extractData(std::ifstream& archiveFile,  
               const ValueType::size_type noValues);  
314    
315    /**    /**
316       \brief       \brief
# Line 435  class DataAbstract { Line 467  class DataAbstract {
467    virtual void    virtual void
468    reorderByReferenceIDs(int *reference_ids);    reorderByReferenceIDs(int *reference_ids);
469    
470   protected:  
471    
472    /**    /**
473       \brief      \brief
474       Set the pointDataView DataArrayView associated with this object.      Return the number of values in the shape for this object.
475      */
476      ESCRIPT_DLL_API
477      int
478      getNoValues() const;
479    
480    
481    
482      /**
483          \brief get a reference to the beginning of a data point
484      */
485      ESCRIPT_DLL_API
486      DataTypes::ValueType::const_reference
487      getDataAtOffset(DataTypes::ValueType::size_type i) const;
488    
489    
490      ESCRIPT_DLL_API
491      DataTypes::ValueType::reference
492      getDataAtOffset(DataTypes::ValueType::size_type i);
493    
494    
495       \param input - Input - The point data view. DataAbstract takes ownership    /**
496       of the DataArrayView provided. It will delete it when it is destructed.      \brief Provide access to underlying storage. Internal use only!
497    */    */
498    ESCRIPT_DLL_API    ESCRIPT_DLL_API
499    void    virtual DataTypes::ValueType&
500    setPointDataView(const DataArrayView& input);    getVector()=0;
501    
502    ESCRIPT_DLL_API    ESCRIPT_DLL_API
503    void    virtual const DataTypes::ValueType&
504    resetPointDataView();    getVector() const=0;
505    
506     protected:
507    
508    //  /**
509    //     \brief
510    //     Set the pointDataView DataArrayView associated with this object.
511    //
512    //     \param input - Input - The point data view. DataAbstract takes ownership
513    //     of the DataArrayView provided. It will delete it when it is destructed.
514    //  */
515    //   ESCRIPT_DLL_API
516    //   void
517    //   setPointDataView(const DataArrayView& input);
518    //
519    //   ESCRIPT_DLL_API
520    //   void
521    //   resetPointDataView();
522    
523    
524    
525    
526    
527    
# Line 470  class DataAbstract { Line 541  class DataAbstract {
541    // The DataArrayView of the data array associated with this object.    // The DataArrayView of the data array associated with this object.
542    // The data array is defined only in child classes of this class, it    // The data array is defined only in child classes of this class, it
543    // is not defined in this abstract parent class.    // is not defined in this abstract parent class.
544    boost::scoped_ptr<DataArrayView> m_pointDataView;  //  boost::scoped_ptr<DataArrayView> m_pointDataView;
545    
546    //    //
547    // A FunctionSpace which provides a description of the data associated    // A FunctionSpace which provides a description of the data associated
548    // with this Data object.    // with this Data object.
549    FunctionSpace m_functionSpace;    FunctionSpace m_functionSpace;
550    
551      //
552      // The shape of the points stored in this view
553      DataTypes::ShapeType m_shape;
554    
555      //
556      // The number of values in each point
557      int m_novalues;
558    
559      //
560      // The rank of the points stored in this view
561      int m_rank;
562    
563  };  };
564    
565    
566    inline
567    DataTypes::ValueType::const_reference
568    DataAbstract::getDataAtOffset(DataTypes::ValueType::size_type i) const
569    {
570        return getVector()[i];
571    }
572    
573    inline
574    DataTypes::ValueType::reference
575    DataAbstract::getDataAtOffset(DataTypes::ValueType::size_type i)
576    {
577        return getVector()[i];
578    }
579    
580    
581  inline  inline
582  bool  bool
583  DataAbstract::validSamplePointNo(int samplePointNo) const  DataAbstract::validSamplePointNo(int samplePointNo) const
# Line 497  inline Line 596  inline
596  DataAbstract::ValueType::value_type*  DataAbstract::ValueType::value_type*
597  DataAbstract::getSampleData(ValueType::size_type sampleNo)  DataAbstract::getSampleData(ValueType::size_type sampleNo)
598  {  {
599    return &(m_pointDataView->getData(getPointOffset(sampleNo,0)));  //   return &(m_pointDataView->getData(getPointOffset(sampleNo,0)));
600      return &(getVector()[getPointOffset(sampleNo,0)]);
601  }  }
602    
603  inline  inline
# Line 522  DataAbstract::getFunctionSpace() const Line 622  DataAbstract::getFunctionSpace() const
622    return m_functionSpace;    return m_functionSpace;
623  }  }
624    
625    // inline
626    // const
627    // DataArrayView&
628    // DataAbstract::getPointDataView() const
629    // {
630    //   return *(m_pointDataView.get());
631    // }
632    
633    // inline
634    // DataArrayView&
635    // DataAbstract::getPointDataView()
636    // {
637    //   return *(m_pointDataView.get());
638    // }
639    
640  inline  inline
641  const  const DataTypes::ShapeType&
642  DataArrayView&  DataAbstract::getShape() const
643  DataAbstract::getPointDataView() const  {
644        return m_shape;
645    }
646    
647    inline
648    int
649    DataAbstract::getRank() const
650  {  {
651    return *(m_pointDataView.get());      return m_rank;
652  }  }
653    
654  inline  inline
655  DataArrayView&  int
656  DataAbstract::getPointDataView()  DataAbstract::getNoValues() const
657  {  {
658    return *(m_pointDataView.get());      return m_novalues;
659  }  }
660    
661  } // end of namespace  } // end of namespace
662    
663  #endif  #endif

Legend:
Removed from v.1795  
changed lines
  Added in v.1796

  ViewVC Help
Powered by ViewVC 1.1.26