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

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

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

revision 1487 by gross, Thu Apr 10 05:28:01 2008 UTC revision 2086 by jfenwick, Mon Nov 24 02:38:50 2008 UTC
# Line 1  Line 1 
1    
 /* $Id$ */  
   
2  /*******************************************************  /*******************************************************
3   *  *
4   *           Copyright 2003-2007 by ACceSS MNRF  * Copyright (c) 2003-2008 by University of Queensland
5   *       Copyright 2007 by University of Queensland  * Earth Systems Science Computational Center (ESSCC)
6   *  * http://www.uq.edu.au/esscc
7   *                http://esscc.uq.edu.au  *
8   *        Primary Business: Queensland, Australia  * Primary Business: Queensland, Australia
9   *  Licensed under the Open Software License version 3.0  * Licensed under the Open Software License version 3.0
10   *     http://www.opensource.org/licenses/osl-3.0.php  * http://www.opensource.org/licenses/osl-3.0.php
11   *  *
12   *******************************************************/  *******************************************************/
13    
14    
15  #include "DataAbstract.h"  #include "DataAbstract.h"
16  #include "DataException.h"  #include "DataException.h"
17    #include "DataLazy.h"
18    
19  using namespace std;  using namespace std;
20    
21  namespace escript {  namespace escript {
22    
23  DataAbstract::DataAbstract(const FunctionSpace& what):  /**
24      m_noDataPointsPerSample(what.getNumDPPSample()),  \brief Returns smart pointer which is managing this object.
25      m_noSamples(what.getNumSamples()),  If one does not exist yet it creates one.
26      m_functionSpace(what)  
27    Note: This is _not_ equivalent to weak_ptr::lock.
28    */
29    DataAbstract_ptr DataAbstract::getPtr()
30  {  {
31      if (_internal_weak_this.expired())
32      {
33        return DataAbstract_ptr(this);  
34      }
35      else
36      {
37        return shared_from_this();
38      }
39  }  }
40    
41  DataAbstract::~DataAbstract()  const_DataAbstract_ptr DataAbstract::getPtr() const
42  {  {
43      if (_internal_weak_this.expired())
44      {
45        return const_DataAbstract_ptr(this);
46      }
47      else
48      {
49        return shared_from_this();
50      }
51  }  }
52    
53  void  bool
54  DataAbstract::setPointDataView(const DataArrayView& input)  DataAbstract::isLazy() const
55  {  {
56      m_pointDataView.reset(new DataArrayView(input.getData(),input.getShape(),input.getOffset()));      return (dynamic_cast<const DataLazy*>(this)!=0);
57  }  }
58    
59  void  
60  DataAbstract::resetPointDataView()  
61    DataAbstract::DataAbstract(const FunctionSpace& what, const ShapeType& shape, bool isDataEmpty):
62        m_noSamples(what.getNumSamples()),
63        m_noDataPointsPerSample(what.getNumDPPSample()),
64        m_functionSpace(what),
65        m_shape(shape),
66        m_novalues(DataTypes::noValues(shape)),
67        m_rank(DataTypes::getRank(shape))
68    
69    {
70        m_isempty=isDataEmpty;
71        if (m_rank>ESCRIPT_MAX_DATA_RANK)
72        {
73        ostringstream os;
74            os << "Error - Attempt to create a rank " << m_rank
75           << " object. The maximum rank is " << ESCRIPT_MAX_DATA_RANK << ".";
76         throw DataException(os.str());
77        }
78    }
79    
80    DataAbstract::~DataAbstract()
81  {  {
     m_pointDataView.reset(new DataArrayView());  
82  }  }
83    
84    
85  void  void
86  DataAbstract::operandCheck(const DataAbstract& right) const  DataAbstract::operandCheck(const DataAbstract& right) const
87  {  {
# Line 63  DataAbstract::operandCheck(const DataAbs Line 102  DataAbstract::operandCheck(const DataAbs
102    
103      //      //
104      // Check the shape of the point data, a rank of 0(scalar) is okay      // Check the shape of the point data, a rank of 0(scalar) is okay
105      if (!((right.getPointDataView().getRank()==0) ||      if (!((right.getRank()==0) || (getRank()==0) ||
106        (right.getPointDataView().getShape()==getPointDataView().getShape())))        (right.getShape()==getShape())))
107        {        {
108          stringstream temp;          stringstream temp;
109      temp << "Error - Right hand argument point data shape: "      temp << "Error - Right hand argument point data shape: "
110           << DataArrayView::shapeToString(right.getPointDataView().getShape())           << DataTypes::shapeToString(right.getShape())
111           << " doesn't match left: "           << " doesn't match left: "
112           << DataArrayView::shapeToString(getPointDataView().getShape());           << DataTypes::shapeToString(getShape());
113      throw DataException(temp.str());      throw DataException(temp.str());
114        }        }
115  }  }
# Line 78  DataAbstract::operandCheck(const DataAbs Line 117  DataAbstract::operandCheck(const DataAbs
117  void  void
118  DataAbstract::dump(const std::string fileName) const  DataAbstract::dump(const std::string fileName) const
119  {  {
120      throw DataException("Error - DataAbstract:: dump: not implemented.");      throw DataException("Error - DataAbstract::dump: not implemented.");
121  }  }
122    
123    
# Line 89  DataAbstract::getSampleDataByTag(int tag Line 128  DataAbstract::getSampleDataByTag(int tag
128      throw DataException("Error - DataAbstract::getSampleDataByTag: Data type does not have tag values.");      throw DataException("Error - DataAbstract::getSampleDataByTag: Data type does not have tag values.");
129  }  }
130    
131  void  
132    void  
133  DataAbstract::setTaggedValue(int tagKey,  DataAbstract::setTaggedValue(int tagKey,
134                               const DataArrayView& value)             const DataTypes::ShapeType& pointshape,
135                   const DataTypes::ValueType& value,
136               int dataOffset)
137  {  {
138      throw DataException("Error - DataAbstract::setTaggedValue: Data type does not have tag values.");      throw DataException("Error - DataAbstract::setTaggedValue: Data type does not have tag values.");
139  }  }
140    
141    
142  int  int
143  DataAbstract::getTagNumber(int dpno)  DataAbstract::getTagNumber(int dpno)
144  {  {
# Line 103  DataAbstract::getTagNumber(int dpno) Line 146  DataAbstract::getTagNumber(int dpno)
146      return (0);      return (0);
147  }  }
148    
 int  
 DataAbstract::archiveData(ofstream& archiveFile,  
                           const ValueType::size_type noValues) const  
 {  
   return 0;  
 }  
149    
 int  
 DataAbstract::extractData(ifstream& archiveFile,  
                           const ValueType::size_type noValues)  
 {  
   return 0;  
 }  
150    
151  void  void
152  DataAbstract::copyAll(const boost::python::numeric::array& value)  DataAbstract::copyAll(const boost::python::numeric::array& value)
# Line 182  DataAbstract::setToZero() Line 213  DataAbstract::setToZero()
213  void  void
214  DataAbstract::reorderByReferenceIDs(int *reference_ids)  DataAbstract::reorderByReferenceIDs(int *reference_ids)
215  {  {
216        throw DataException("Error - DataAbstract:: cannot reorder by reference ids.");
217  }  }
218    
219    
220    // DataTypes::ValueType&
221    // DataAbstract::getVector()
222    // {
223    //    throw DataException("Error - DataAbstract:: does not have a DataVector.");
224    // }
225    //
226    // const DataTypes::ValueType&
227    // DataAbstract::getVector() const
228    // {
229    //    throw DataException("Error - DataAbstract:: does not have a DataVector.");
230    // }
231    
232    
233    
234    
235  }  // end of namespace  }  // end of namespace

Legend:
Removed from v.1487  
changed lines
  Added in v.2086

  ViewVC Help
Powered by ViewVC 1.1.26