/[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 2084 by jfenwick, Fri Nov 21 05:20:42 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_pointDataView.reset(new DataArrayView());      m_isempty=isDataEmpty;
71  }  }
72    
73    DataAbstract::~DataAbstract()
74    {
75    }
76    
77    
78  void  void
79  DataAbstract::operandCheck(const DataAbstract& right) const  DataAbstract::operandCheck(const DataAbstract& right) const
80  {  {
# Line 63  DataAbstract::operandCheck(const DataAbs Line 95  DataAbstract::operandCheck(const DataAbs
95    
96      //      //
97      // 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
98      if (!((right.getPointDataView().getRank()==0) ||      if (!((right.getRank()==0) || (getRank()==0) ||
99        (right.getPointDataView().getShape()==getPointDataView().getShape())))        (right.getShape()==getShape())))
100        {        {
101          stringstream temp;          stringstream temp;
102      temp << "Error - Right hand argument point data shape: "      temp << "Error - Right hand argument point data shape: "
103           << DataArrayView::shapeToString(right.getPointDataView().getShape())           << DataTypes::shapeToString(right.getShape())
104           << " doesn't match left: "           << " doesn't match left: "
105           << DataArrayView::shapeToString(getPointDataView().getShape());           << DataTypes::shapeToString(getShape());
106      throw DataException(temp.str());      throw DataException(temp.str());
107        }        }
108  }  }
# Line 78  DataAbstract::operandCheck(const DataAbs Line 110  DataAbstract::operandCheck(const DataAbs
110  void  void
111  DataAbstract::dump(const std::string fileName) const  DataAbstract::dump(const std::string fileName) const
112  {  {
113      throw DataException("Error - DataAbstract:: dump: not implemented.");      throw DataException("Error - DataAbstract::dump: not implemented.");
114  }  }
115    
116    
# Line 89  DataAbstract::getSampleDataByTag(int tag Line 121  DataAbstract::getSampleDataByTag(int tag
121      throw DataException("Error - DataAbstract::getSampleDataByTag: Data type does not have tag values.");      throw DataException("Error - DataAbstract::getSampleDataByTag: Data type does not have tag values.");
122  }  }
123    
124  void  
125    void  
126  DataAbstract::setTaggedValue(int tagKey,  DataAbstract::setTaggedValue(int tagKey,
127                               const DataArrayView& value)             const DataTypes::ShapeType& pointshape,
128                   const DataTypes::ValueType& value,
129               int dataOffset)
130  {  {
131      throw DataException("Error - DataAbstract::setTaggedValue: Data type does not have tag values.");      throw DataException("Error - DataAbstract::setTaggedValue: Data type does not have tag values.");
132  }  }
133    
134    
135  int  int
136  DataAbstract::getTagNumber(int dpno)  DataAbstract::getTagNumber(int dpno)
137  {  {
# Line 103  DataAbstract::getTagNumber(int dpno) Line 139  DataAbstract::getTagNumber(int dpno)
139      return (0);      return (0);
140  }  }
141    
 int  
 DataAbstract::archiveData(ofstream& archiveFile,  
                           const ValueType::size_type noValues) const  
 {  
   return 0;  
 }  
142    
 int  
 DataAbstract::extractData(ifstream& archiveFile,  
                           const ValueType::size_type noValues)  
 {  
   return 0;  
 }  
143    
144  void  void
145  DataAbstract::copyAll(const boost::python::numeric::array& value)  DataAbstract::copyAll(const boost::python::numeric::array& value)
# Line 182  DataAbstract::setToZero() Line 206  DataAbstract::setToZero()
206  void  void
207  DataAbstract::reorderByReferenceIDs(int *reference_ids)  DataAbstract::reorderByReferenceIDs(int *reference_ids)
208  {  {
209        throw DataException("Error - DataAbstract:: cannot reorder by reference ids.");
210  }  }
211    
212    
213    // DataTypes::ValueType&
214    // DataAbstract::getVector()
215    // {
216    //    throw DataException("Error - DataAbstract:: does not have a DataVector.");
217    // }
218    //
219    // const DataTypes::ValueType&
220    // DataAbstract::getVector() const
221    // {
222    //    throw DataException("Error - DataAbstract:: does not have a DataVector.");
223    // }
224    
225    
226    
227    
228  }  // end of namespace  }  // end of namespace

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

  ViewVC Help
Powered by ViewVC 1.1.26