/[escript]/branches/more_shared_ptrs_from_1812/escript/src/DataAbstract.cpp
ViewVC logotype

Annotation of /branches/more_shared_ptrs_from_1812/escript/src/DataAbstract.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1828 - (hide annotations)
Thu Oct 2 04:52:11 2008 UTC (11 years, 11 months ago) by jfenwick
File size: 5534 byte(s)
Branch commit.
Added getPtr to DataAbstract.
Passes all unit tests.


1 jgs 82
2 ksteube 1312 /*******************************************************
3 ksteube 1811 *
4     * Copyright (c) 2003-2008 by University of Queensland
5     * Earth Systems Science Computational Center (ESSCC)
6     * http://www.uq.edu.au/esscc
7     *
8     * Primary Business: Queensland, Australia
9     * Licensed under the Open Software License version 3.0
10     * http://www.opensource.org/licenses/osl-3.0.php
11     *
12     *******************************************************/
13 ksteube 1312
14 ksteube 1811
15 jgs 474 #include "DataAbstract.h"
16     #include "DataException.h"
17 jgs 82
18     using namespace std;
19    
20     namespace escript {
21    
22 jfenwick 1828 /**
23     \brief Returns smart pointer which is managing this object.
24     If one does not exist yet it creates one.
25    
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     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    
53    
54 jfenwick 1803 DataAbstract::DataAbstract(const FunctionSpace& what, const ShapeType& shape, bool isDataEmpty):
55 jgs 82 m_noDataPointsPerSample(what.getNumDPPSample()),
56     m_noSamples(what.getNumSamples()),
57 jfenwick 1796 m_functionSpace(what),
58     m_shape(shape),
59     m_rank(DataTypes::getRank(shape)),
60     m_novalues(DataTypes::noValues(shape))
61 jgs 82 {
62 jfenwick 1803 m_isempty=isDataEmpty;
63 jgs 82 }
64    
65     DataAbstract::~DataAbstract()
66     {
67     }
68    
69    
70 jgs 119 void
71 jgs 82 DataAbstract::operandCheck(const DataAbstract& right) const
72     {
73     if ((right.getNumDPPSample()!=getNumDPPSample()) ||
74     (right.getNumSamples()!=getNumSamples()) ||
75     (right.getFunctionSpace()!=getFunctionSpace())) {
76     stringstream temp;
77     temp << "Error - Right hand argument sample shape or function space "
78     << "incompatible with left." << endl
79     << "LHS: (" << getNumSamples() << ","
80     << getNumDPPSample() << ") " << getFunctionSpace().toString()
81     << endl
82     << "RHS: (" << right.getNumSamples() << ","
83     << right.getNumDPPSample() << ") "
84     << right.getFunctionSpace().toString();
85     throw DataException(temp.str());
86     }
87    
88     //
89     // Check the shape of the point data, a rank of 0(scalar) is okay
90 jfenwick 1796 if (!((right.getRank()==0) ||
91     (right.getShape()==getShape())))
92 jgs 82 {
93     stringstream temp;
94     temp << "Error - Right hand argument point data shape: "
95 jfenwick 1796 << DataTypes::shapeToString(right.getShape())
96 jgs 82 << " doesn't match left: "
97 jfenwick 1796 << DataTypes::shapeToString(getShape());
98 jgs 82 throw DataException(temp.str());
99     }
100     }
101    
102 gross 950 void
103     DataAbstract::dump(const std::string fileName) const
104     {
105 jfenwick 1803 throw DataException("Error - DataAbstract::dump: not implemented.");
106 gross 950 }
107    
108    
109    
110 jgs 82 DataAbstract::ValueType::value_type*
111     DataAbstract::getSampleDataByTag(int tag)
112     {
113 jgs 110 throw DataException("Error - DataAbstract::getSampleDataByTag: Data type does not have tag values.");
114 jgs 82 }
115    
116 jfenwick 1796
117     void
118 jgs 82 DataAbstract::setTaggedValue(int tagKey,
119 jfenwick 1796 const DataTypes::ShapeType& pointshape,
120     const DataTypes::ValueType& value,
121     int dataOffset)
122 jgs 82 {
123 jgs 110 throw DataException("Error - DataAbstract::setTaggedValue: Data type does not have tag values.");
124 jgs 82 }
125    
126 jfenwick 1796
127 jgs 149 int
128     DataAbstract::getTagNumber(int dpno)
129     {
130     throw DataException("Error - DataAbstract::getTagNumber: Data type cannot be accessed by tag values.");
131     return (0);
132     }
133    
134 jgs 123
135    
136 jgs 126 void
137     DataAbstract::copyAll(const boost::python::numeric::array& value)
138     {
139     throw DataException("Error - DataAbstract::copying data from numarray objects is not supported.");
140     }
141 gross 921 void
142 gross 922 DataAbstract::copyToDataPoint(const int sampleNo, const int dataPointNo, const double value)
143     {
144     throw DataException("Error - DataAbstract::copying data from double value to a single data point is not supported.");
145     }
146     void
147 gross 921 DataAbstract::copyToDataPoint(const int sampleNo, const int dataPointNo, const boost::python::numeric::array& value)
148     {
149     throw DataException("Error - DataAbstract::copying data from numarray objects to a single data point is not supported.");
150     }
151 jgs 126
152 gross 576 void
153 ksteube 775 DataAbstract::symmetric(DataAbstract* ev)
154     {
155     throw DataException("Error - DataAbstract::symmetric is not supported.");
156     }
157    
158     void
159     DataAbstract::nonsymmetric(DataAbstract* ev)
160     {
161     throw DataException("Error - DataAbstract::nonsymmetric is not supported.");
162     }
163    
164     void
165 gross 800 DataAbstract::trace(DataAbstract* ev, int axis_offset)
166 ksteube 775 {
167 gross 800 throw DataException("Error - DataAbstract::trace is not supported.");
168 ksteube 775 }
169    
170     void
171 gross 804 DataAbstract::swapaxes(DataAbstract* ev, int axis0, int axis1)
172 gross 800 {
173 gross 804 throw DataException("Error - DataAbstract::component swapaxes is not supported.");
174 gross 800 }
175     void
176 ksteube 775 DataAbstract::transpose(DataAbstract* ev, int axis_offset)
177     {
178     throw DataException("Error - DataAbstract::transpose is not supported.");
179     }
180    
181     void
182 gross 576 DataAbstract::eigenvalues(DataAbstract* ev)
183     {
184     throw DataException("Error - DataAbstract::eigenvalues is not supported.");
185     }
186     void
187     DataAbstract::eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol)
188     {
189     throw DataException("Error - DataAbstract::eigenvalues_and_eigenvectors is not supported.");
190    
191     }
192 gross 1118 void
193     DataAbstract::setToZero()
194     {
195     throw DataException("Error - DataAbstract:: cannot set values to zero.");
196     }
197 gross 576
198 gross 1487 void
199     DataAbstract::reorderByReferenceIDs(int *reference_ids)
200     {
201 jfenwick 1803 throw DataException("Error - DataAbstract:: cannot reorder by reference ids.");
202 gross 1487 }
203 gross 576
204    
205 jfenwick 1796 DataTypes::ValueType&
206     DataAbstract::getVector()
207     {
208     throw DataException("Error - DataAbstract:: does not have a DataVector.");
209     }
210 gross 1487
211 jfenwick 1796 const DataTypes::ValueType&
212     DataAbstract::getVector() const
213     {
214     throw DataException("Error - DataAbstract:: does not have a DataVector.");
215     }
216 gross 1487
217 jfenwick 1796
218    
219    
220 jgs 82 } // end of namespace

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26