/[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 1946 by jfenwick, Wed Oct 29 05:48:53 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"
# Line 20  using namespace std; Line 19  using namespace std;
19    
20  namespace escript {  namespace escript {
21    
22  DataAbstract::DataAbstract(const FunctionSpace& what):  /**
23      m_noDataPointsPerSample(what.getNumDPPSample()),  \brief Returns smart pointer which is managing this object.
24      m_noSamples(what.getNumSamples()),  If one does not exist yet it creates one.
25      m_functionSpace(what)  
26    Note: This is _not_ equivalent to weak_ptr::lock.
27    */
28    DataAbstract_ptr DataAbstract::getPtr()
29  {  {
30      if (_internal_weak_this.expired())
31      {
32        return DataAbstract_ptr(this);  
33      }
34      else
35      {
36        return shared_from_this();
37      }
38  }  }
39    
40  DataAbstract::~DataAbstract()  const_DataAbstract_ptr DataAbstract::getPtr() const
41  {  {
42      if (_internal_weak_this.expired())
43      {
44        return const_DataAbstract_ptr(this);
45      }
46      else
47      {
48        return shared_from_this();
49      }
50  }  }
51    
52  void  
53  DataAbstract::setPointDataView(const DataArrayView& input)  
54    DataAbstract::DataAbstract(const FunctionSpace& what, const ShapeType& shape, bool isDataEmpty):
55        m_noSamples(what.getNumSamples()),
56        m_noDataPointsPerSample(what.getNumDPPSample()),
57        m_functionSpace(what),
58        m_shape(shape),
59        m_novalues(DataTypes::noValues(shape)),
60        m_rank(DataTypes::getRank(shape))
61    
62  {  {
63      m_pointDataView.reset(new DataArrayView(input.getData(),input.getShape(),input.getOffset()));      m_isempty=isDataEmpty;
64  }  }
65    
66  void  DataAbstract::~DataAbstract()
 DataAbstract::resetPointDataView()  
67  {  {
     m_pointDataView.reset(new DataArrayView());  
68  }  }
69    
70    
71  void  void
72  DataAbstract::operandCheck(const DataAbstract& right) const  DataAbstract::operandCheck(const DataAbstract& right) const
73  {  {
# Line 63  DataAbstract::operandCheck(const DataAbs Line 88  DataAbstract::operandCheck(const DataAbs
88    
89      //      //
90      // 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
91      if (!((right.getPointDataView().getRank()==0) ||      if (!((right.getRank()==0) ||
92        (right.getPointDataView().getShape()==getPointDataView().getShape())))        (right.getShape()==getShape())))
93        {        {
94          stringstream temp;          stringstream temp;
95      temp << "Error - Right hand argument point data shape: "      temp << "Error - Right hand argument point data shape: "
96           << DataArrayView::shapeToString(right.getPointDataView().getShape())           << DataTypes::shapeToString(right.getShape())
97           << " doesn't match left: "           << " doesn't match left: "
98           << DataArrayView::shapeToString(getPointDataView().getShape());           << DataTypes::shapeToString(getShape());
99      throw DataException(temp.str());      throw DataException(temp.str());
100        }        }
101  }  }
# Line 78  DataAbstract::operandCheck(const DataAbs Line 103  DataAbstract::operandCheck(const DataAbs
103  void  void
104  DataAbstract::dump(const std::string fileName) const  DataAbstract::dump(const std::string fileName) const
105  {  {
106      throw DataException("Error - DataAbstract:: dump: not implemented.");      throw DataException("Error - DataAbstract::dump: not implemented.");
107  }  }
108    
109    
# Line 89  DataAbstract::getSampleDataByTag(int tag Line 114  DataAbstract::getSampleDataByTag(int tag
114      throw DataException("Error - DataAbstract::getSampleDataByTag: Data type does not have tag values.");      throw DataException("Error - DataAbstract::getSampleDataByTag: Data type does not have tag values.");
115  }  }
116    
117  void  
118    void  
119  DataAbstract::setTaggedValue(int tagKey,  DataAbstract::setTaggedValue(int tagKey,
120                               const DataArrayView& value)             const DataTypes::ShapeType& pointshape,
121                   const DataTypes::ValueType& value,
122               int dataOffset)
123  {  {
124      throw DataException("Error - DataAbstract::setTaggedValue: Data type does not have tag values.");      throw DataException("Error - DataAbstract::setTaggedValue: Data type does not have tag values.");
125  }  }
126    
127    
128  int  int
129  DataAbstract::getTagNumber(int dpno)  DataAbstract::getTagNumber(int dpno)
130  {  {
# Line 103  DataAbstract::getTagNumber(int dpno) Line 132  DataAbstract::getTagNumber(int dpno)
132      return (0);      return (0);
133  }  }
134    
 int  
 DataAbstract::archiveData(ofstream& archiveFile,  
                           const ValueType::size_type noValues) const  
 {  
   return 0;  
 }  
135    
 int  
 DataAbstract::extractData(ifstream& archiveFile,  
                           const ValueType::size_type noValues)  
 {  
   return 0;  
 }  
136    
137  void  void
138  DataAbstract::copyAll(const boost::python::numeric::array& value)  DataAbstract::copyAll(const boost::python::numeric::array& value)
# Line 182  DataAbstract::setToZero() Line 199  DataAbstract::setToZero()
199  void  void
200  DataAbstract::reorderByReferenceIDs(int *reference_ids)  DataAbstract::reorderByReferenceIDs(int *reference_ids)
201  {  {
202        throw DataException("Error - DataAbstract:: cannot reorder by reference ids.");
203    }
204    
205    
206    DataTypes::ValueType&
207    DataAbstract::getVector()
208    {
209       throw DataException("Error - DataAbstract:: does not have a DataVector.");
210    }
211    
212    const DataTypes::ValueType&
213    DataAbstract::getVector() const
214    {
215       throw DataException("Error - DataAbstract:: does not have a DataVector.");
216  }  }
217    
218    

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

  ViewVC Help
Powered by ViewVC 1.1.26