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

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

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

revision 2742 by jfenwick, Thu Nov 12 06:03:37 2009 UTC revision 2770 by jfenwick, Wed Nov 25 01:24:51 2009 UTC
# Line 41  extern "C" { Line 41  extern "C" {
41  #include <boost/python/object.hpp>  #include <boost/python/object.hpp>
42  #include <boost/python/tuple.hpp>  #include <boost/python/tuple.hpp>
43    
 #include "BufferGroup.h"  
   
44  namespace escript {  namespace escript {
45    
46  //  //
# Line 322  class Data { Line 320  class Data {
320    escriptDataC    escriptDataC
321    getDataC() const;    getDataC() const;
322    
   /**  
     \brief How much space is required to evaulate a sample of the Data.  
   */  
   ESCRIPT_DLL_API  
   size_t  
   getSampleBufferSize() const;  
   
   
323    
324    /**    /**
325       \brief       \brief
# Line 576  If false, the result is a list of scalar Line 566  If false, the result is a list of scalar
566      preferred interface but is provided for use by C code.      preferred interface but is provided for use by C code.
567      The bufferg parameter is only required for LazyData.      The bufferg parameter is only required for LazyData.
568      \param sampleNo - Input - the given sample no.      \param sampleNo - Input - the given sample no.
     \param bufferg - A buffer to compute (and store) sample data in will be selected from this group.  
569      \return pointer to the sample data.      \return pointer to the sample data.
570  */  */
571    ESCRIPT_DLL_API    ESCRIPT_DLL_API
572    inline    inline
573    const DataAbstract::ValueType::value_type*    const DataAbstract::ValueType::value_type*
574    getSampleDataRO(DataAbstract::ValueType::size_type sampleNo, BufferGroup* bufferg=0);    getSampleDataRO(DataAbstract::ValueType::size_type sampleNo);
575    
576    
577    /**    /**
# Line 1518  instead of manually manipulating process Line 1507  instead of manually manipulating process
1507          getDataAtOffsetRW(DataTypes::ValueType::size_type i);          getDataAtOffsetRW(DataTypes::ValueType::size_type i);
1508    
1509    
1510    
 /**  
    \brief Create a buffer for use by getSample  
    Allocates a DataVector large enough for DataLazy::resolveSample to operate on for the current Data.  
    Do not use this buffer for other Data instances (unless you are sure they will be the same size).  
     
    In multi-threaded sections, this needs to be called on each thread.  
   
    \return A BufferGroup* if Data is lazy, NULL otherwise.  
    \warning This pointer must be deallocated using freeSampleBuffer to avoid cross library memory issues.  
 */  
   ESCRIPT_DLL_API  
   BufferGroup*  
   allocSampleBuffer() const;  
   
 /**  
    \brief Free a buffer allocated with allocSampleBuffer.  
    \param buffer Input - pointer to the buffer to deallocate.  
 */  
 ESCRIPT_DLL_API void freeSampleBuffer(BufferGroup* buffer);  
   
1511   protected:   protected:
1512    
1513   private:   private:
# Line 1851  Data::getSampleDataRW(DataAbstract::Valu Line 1820  Data::getSampleDataRW(DataAbstract::Valu
1820    
1821  inline  inline
1822  const DataAbstract::ValueType::value_type*  const DataAbstract::ValueType::value_type*
1823  Data::getSampleDataRO(DataAbstract::ValueType::size_type sampleNo, BufferGroup* bufferg)  Data::getSampleDataRO(DataAbstract::ValueType::size_type sampleNo)
1824  {  {
1825     DataLazy* l=dynamic_cast<DataLazy*>(m_data.get());     DataLazy* l=dynamic_cast<DataLazy*>(m_data.get());
1826     if (l!=0)     if (l!=0)
1827     {     {
1828      size_t offset=0;      size_t offset=0;
1829      if (bufferg==NULL)      const DataTypes::ValueType* res=l->resolveSample(sampleNo,offset);
     {  
         throw DataException("Error, attempt to getSampleDataRO for lazy Data with buffer==NULL");  
     }  
     const DataTypes::ValueType* res=l->resolveSample(*bufferg,sampleNo,offset);  
1830      return &((*res)[offset]);      return &((*res)[offset]);
1831     }     }
1832     return getReady()->getSampleDataRO(sampleNo);     return getReady()->getSampleDataRO(sampleNo);

Legend:
Removed from v.2742  
changed lines
  Added in v.2770

  ViewVC Help
Powered by ViewVC 1.1.26