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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1803 - (show annotations)
Wed Sep 24 06:20:29 2008 UTC (10 years, 10 months ago) by jfenwick
File size: 2139 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 #include "DataEmpty.h"
17 #include "DataException.h"
18
19
20 namespace {
21
22
23 inline
24 void
25 throwStandardException(const std::string& functionName)
26 {
27 throw escript::DataException("Error - "+functionName+" function call invalid for DataEmpty.");
28 }
29
30
31 escript::DataTypes::ValueType dummy;
32
33 }
34
35 namespace escript {
36
37 DataEmpty::DataEmpty() :
38 DataAbstract(FunctionSpace(),DataTypes::scalarShape, true)
39 {
40
41 }
42
43 DataEmpty::~DataEmpty()
44 {
45 }
46
47 std::string
48 DataEmpty::toString() const
49 {
50 return "(Empty Data)";
51 }
52
53
54 DataAbstract*
55 DataEmpty::deepCopy()
56 {
57 return new DataEmpty();
58 }
59
60 DataTypes::ValueType::size_type
61 DataEmpty::getPointOffset(int sampleNo,
62 int dataPointNo) const
63 {
64 throwStandardException("getPointOffset");
65 return 0;
66 }
67
68 DataTypes::ValueType::size_type
69 DataEmpty::getLength() const
70 {
71 return 0;
72 }
73
74 DataAbstract*
75 DataEmpty::getSlice(const DataTypes::RegionType& region) const
76 {
77 throwStandardException("getSlice");
78 return 0;
79 }
80
81 void
82 DataEmpty::setSlice(const DataAbstract* value,
83 const DataTypes::RegionType& region)
84 {
85 throwStandardException("setSlice");
86 }
87
88
89
90 DataTypes::ValueType&
91 DataEmpty::getVector()
92 {
93 throwStandardException("getVector"); // always throws but the compiler doesn't know that.
94 return dummy; // dead code to stop the compiler complaining
95 }
96
97 const DataTypes::ValueType&
98 DataEmpty::getVector() const
99 {
100 throwStandardException("getVector"); // always throws but the compiler doesn't know that.
101 return dummy; // dead code to stop the compiler complaining
102 }
103
104
105 void
106 DataEmpty::dump(const std::string fileName) const
107 {
108 throw DataException("Error - Cannot dump() a DataEmpty object.");
109 }
110
111 } // end of namespace

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26