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

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

Parent Directory Parent Directory | Revision Log Revision Log


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


1
2 /*******************************************************
3 *
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
14
15 #include "DataAbstract.h"
16 #include "DataException.h"
17
18 using namespace std;
19
20 namespace escript {
21
22 /**
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 DataAbstract::DataAbstract(const FunctionSpace& what, const ShapeType& shape, bool isDataEmpty):
55 m_noDataPointsPerSample(what.getNumDPPSample()),
56 m_noSamples(what.getNumSamples()),
57 m_functionSpace(what),
58 m_shape(shape),
59 m_rank(DataTypes::getRank(shape)),
60 m_novalues(DataTypes::noValues(shape))
61 {
62 m_isempty=isDataEmpty;
63 }
64
65 DataAbstract::~DataAbstract()
66 {
67 }
68
69
70 void
71 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 if (!((right.getRank()==0) ||
91 (right.getShape()==getShape())))
92 {
93 stringstream temp;
94 temp << "Error - Right hand argument point data shape: "
95 << DataTypes::shapeToString(right.getShape())
96 << " doesn't match left: "
97 << DataTypes::shapeToString(getShape());
98 throw DataException(temp.str());
99 }
100 }
101
102 void
103 DataAbstract::dump(const std::string fileName) const
104 {
105 throw DataException("Error - DataAbstract::dump: not implemented.");
106 }
107
108
109
110 DataAbstract::ValueType::value_type*
111 DataAbstract::getSampleDataByTag(int tag)
112 {
113 throw DataException("Error - DataAbstract::getSampleDataByTag: Data type does not have tag values.");
114 }
115
116
117 void
118 DataAbstract::setTaggedValue(int tagKey,
119 const DataTypes::ShapeType& pointshape,
120 const DataTypes::ValueType& value,
121 int dataOffset)
122 {
123 throw DataException("Error - DataAbstract::setTaggedValue: Data type does not have tag values.");
124 }
125
126
127 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
135
136 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 void
142 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 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
152 void
153 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 DataAbstract::trace(DataAbstract* ev, int axis_offset)
166 {
167 throw DataException("Error - DataAbstract::trace is not supported.");
168 }
169
170 void
171 DataAbstract::swapaxes(DataAbstract* ev, int axis0, int axis1)
172 {
173 throw DataException("Error - DataAbstract::component swapaxes is not supported.");
174 }
175 void
176 DataAbstract::transpose(DataAbstract* ev, int axis_offset)
177 {
178 throw DataException("Error - DataAbstract::transpose is not supported.");
179 }
180
181 void
182 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 void
193 DataAbstract::setToZero()
194 {
195 throw DataException("Error - DataAbstract:: cannot set values to zero.");
196 }
197
198 void
199 DataAbstract::reorderByReferenceIDs(int *reference_ids)
200 {
201 throw DataException("Error - DataAbstract:: cannot reorder by reference ids.");
202 }
203
204
205 DataTypes::ValueType&
206 DataAbstract::getVector()
207 {
208 throw DataException("Error - DataAbstract:: does not have a DataVector.");
209 }
210
211 const DataTypes::ValueType&
212 DataAbstract::getVector() const
213 {
214 throw DataException("Error - DataAbstract:: does not have a DataVector.");
215 }
216
217
218
219
220 } // end of namespace

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26