/[escript]/trunk/escript/src/DataEmpty.h
ViewVC logotype

Contents of /trunk/escript/src/DataEmpty.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1803 - (show annotations)
Wed Sep 24 06:20:29 2008 UTC (10 years, 11 months ago) by jfenwick
File MIME type: text/plain
File size: 4002 byte(s)
All about making DataEmpty instances throw.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Exposed getDim from AbstractDomain to python to fix bug.

Added isEmpty member to DataAbstract to allow it to throw is queries are 
made about a DataEmpty instance.


Added exceptions to DataAbstract, DataEmpty and Data to prevent calls 
being made against DataEmpty objects.
The following still work as expected on DataEmpty instances

copy, getDomain, getFunctionSpace, isEmpty, isExpanded, isProtected, 
isTagged, setprotection.

You can also call interpolate, however it should throw if you try to 
change FunctionSpaces.


1
2 /* $Id$ */
3
4 /*******************************************************
5 *
6 * Copyright 2003-2007 by ACceSS MNRF
7 * Copyright 2007 by University of Queensland
8 *
9 * http://esscc.uq.edu.au
10 * Primary Business: Queensland, Australia
11 * Licensed under the Open Software License version 3.0
12 * http://www.opensource.org/licenses/osl-3.0.php
13 *
14 *******************************************************/
15
16 #if !defined escript_DataEmpty_20040726_H
17 #define escript_DataEmpty_20040726_H
18 #include "system_dep.h"
19
20 #include "DataAbstract.h"
21
22 namespace escript {
23
24 /**
25 \brief
26 Implements the DataAbstract interface for an empty Data object.
27
28 Description:
29 Implements the DataAbstract interface for an empty Data object.
30 */
31
32 class DataEmpty : public DataAbstract {
33
34 public:
35
36 /**
37 \brief
38 Default constructor for DataEmpty.
39
40 Description:
41 Default constructor for DataEmpty.
42
43 */
44 ESCRIPT_DLL_API
45 DataEmpty();
46
47 /**
48 \brief
49 Destructor for DataEmpty.
50 */
51 ESCRIPT_DLL_API
52 virtual
53 ~DataEmpty();
54
55 /**
56 \brief
57 Return a textual representation of the Data object.
58 */
59 ESCRIPT_DLL_API
60 virtual
61 std::string
62 toString() const;
63
64 /**
65 \brief Return a deep copy of the current object.
66 */
67 ESCRIPT_DLL_API
68 virtual
69 DataAbstract*
70 deepCopy();
71
72
73 /**
74 \brief
75 Return the offset for the given sample.
76 NB: This will throw an exception as obviously an empty Data object contains no
77 samples. An implementation is required by parent DataAbstract class.
78 \param sampleNo - Input - Sample number.
79 \param dataPointNo - Input - data-point number.
80 */
81 ESCRIPT_DLL_API
82 virtual
83 DataTypes::ValueType::size_type
84 getPointOffset(int sampleNo,
85 int dataPointNo) const;
86
87 // /**
88 /* \brief
89 Return a view into the data for the data point specified.
90 NB: This will throw an exception as obviously an empty Data object contains no
91 data points. An implementation is required by parent DataAbstract class.
92 \param sampleNo - Input - Sample number.
93 \param dataPointNo - Input - data-point number.*/
94 // */
95 // ESCRIPT_DLL_API
96 // virtual
97 // DataArrayView
98 // getDataPoint(int sampleNo,
99 // int dataPointNo);
100
101 /**
102 \brief
103 Return the number of doubles stored for the Data object.
104 As this is an empty Data object, this method will always return 0.
105 */
106 ESCRIPT_DLL_API
107 virtual
108 ValueType::size_type
109 getLength() const;
110
111 /**
112 \brief
113 Factory method that returns a newly created DataEmpty sliced from the
114 current Data object according to the specified region.
115 NB: This will throw an exception as obviously an empty Data object contains no
116 data to slice from. An implementation is required by parent DataAbstract class.
117 */
118 ESCRIPT_DLL_API
119 virtual
120 DataAbstract*
121 getSlice(const DataTypes::RegionType& region) const;
122
123 /**
124 \brief
125 Set the current Data object according to the specified slice from the
126 given input value.
127 NB: This will throw an exception as obviously an empty Data object contains no
128 data to slice to. An implementation is required by parent DataAbstract class.
129 \param value Input - Data to copy from
130 \param region Input - Region to copy.
131 */
132 ESCRIPT_DLL_API
133 virtual
134 void
135 setSlice(const DataAbstract* value,
136 const DataTypes::RegionType& region);
137
138
139 void
140 dump(const std::string fileName) const;
141
142 protected:
143
144 /**
145 \brief Provide access to underlying storage. Internal use only!
146 */
147 ESCRIPT_DLL_API
148 virtual DataTypes::ValueType&
149 getVector();
150
151 ESCRIPT_DLL_API
152 virtual const DataTypes::ValueType&
153 getVector() const;
154
155 private:
156
157 // /**
158 /* \brief
159 Throw a standard exception. This function is called if an attempt
160 is made to use functions of DataEmpty that are not valid.*/
161 // */
162 // void
163 // throwStandardException(const std::string& functionName) const;
164
165 };
166
167 } // end of namespace
168
169 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26