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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1803 - (hide annotations)
Wed Sep 24 06:20:29 2008 UTC (11 years, 1 month 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 jgs 121
2 ksteube 1312 /* $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 jgs 102 #if !defined escript_DataEmpty_20040726_H
17 jgs 82 #define escript_DataEmpty_20040726_H
18 woo409 757 #include "system_dep.h"
19 jgs 82
20     #include "DataAbstract.h"
21    
22     namespace escript {
23    
24     /**
25     \brief
26 jgs 102 Implements the DataAbstract interface for an empty Data object.
27 jgs 82
28     Description:
29 jgs 102 Implements the DataAbstract interface for an empty Data object.
30 jgs 82 */
31 jgs 121
32 jgs 102 class DataEmpty : public DataAbstract {
33 jgs 82
34     public:
35    
36     /**
37     \brief
38 jgs 102 Default constructor for DataEmpty.
39 jgs 82
40     Description:
41 jgs 102 Default constructor for DataEmpty.
42 jgs 82
43     */
44 woo409 757 ESCRIPT_DLL_API
45 jgs 82 DataEmpty();
46 jgs 102
47 jgs 82 /**
48     \brief
49 jgs 102 Destructor for DataEmpty.
50 jgs 82 */
51 woo409 757 ESCRIPT_DLL_API
52 jgs 102 virtual
53     ~DataEmpty();
54    
55 jgs 82 /**
56     \brief
57 jgs 102 Return a textual representation of the Data object.
58 jgs 82 */
59 woo409 757 ESCRIPT_DLL_API
60 jgs 102 virtual
61     std::string
62     toString() const;
63    
64 jgs 82 /**
65 jfenwick 1799 \brief Return a deep copy of the current object.
66     */
67     ESCRIPT_DLL_API
68     virtual
69     DataAbstract*
70     deepCopy();
71    
72    
73     /**
74 jgs 82 \brief
75 jgs 121 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 jgs 102 \param sampleNo - Input - Sample number.
79     \param dataPointNo - Input - data-point number.
80 jgs 82 */
81 woo409 757 ESCRIPT_DLL_API
82 jgs 102 virtual
83 jfenwick 1796 DataTypes::ValueType::size_type
84 jgs 102 getPointOffset(int sampleNo,
85     int dataPointNo) const;
86    
87 jfenwick 1796 // /**
88     /* \brief
89 jgs 82 Return a view into the data for the data point specified.
90 jgs 121 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 jgs 102 \param sampleNo - Input - Sample number.
93 jfenwick 1796 \param dataPointNo - Input - data-point number.*/
94     // */
95     // ESCRIPT_DLL_API
96     // virtual
97     // DataArrayView
98     // getDataPoint(int sampleNo,
99     // int dataPointNo);
100 jgs 102
101     /**
102 jgs 82 \brief
103 jgs 102 Return the number of doubles stored for the Data object.
104 jgs 121 As this is an empty Data object, this method will always return 0.
105 jgs 82 */
106 woo409 757 ESCRIPT_DLL_API
107 jgs 102 virtual
108     ValueType::size_type
109     getLength() const;
110    
111 jgs 82 /**
112     \brief
113 jgs 102 Factory method that returns a newly created DataEmpty sliced from the
114     current Data object according to the specified region.
115 jgs 121 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 jgs 82 */
118 woo409 757 ESCRIPT_DLL_API
119 jgs 102 virtual
120     DataAbstract*
121 jfenwick 1796 getSlice(const DataTypes::RegionType& region) const;
122 jgs 102
123     /**
124 jgs 82 \brief
125 jgs 102 Set the current Data object according to the specified slice from the
126     given input value.
127 jgs 121 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 jgs 82 \param value Input - Data to copy from
130     \param region Input - Region to copy.
131     */
132 woo409 757 ESCRIPT_DLL_API
133 jgs 102 virtual
134     void
135     setSlice(const DataAbstract* value,
136 jfenwick 1796 const DataTypes::RegionType& region);
137 jgs 102
138 jfenwick 1803
139     void
140     dump(const std::string fileName) const;
141    
142 jgs 82 protected:
143    
144 jfenwick 1796 /**
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 jgs 82 private:
156 jgs 102
157 jfenwick 1796 // /**
158     /* \brief
159 jgs 121 Throw a standard exception. This function is called if an attempt
160 jfenwick 1796 is made to use functions of DataEmpty that are not valid.*/
161     // */
162     // void
163     // throwStandardException(const std::string& functionName) const;
164 jgs 121
165 jgs 82 };
166    
167     } // end of namespace
168 jgs 121
169 jgs 82 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26