Teuchos - Trilinos Tools Package
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
parameterlist
src
Teuchos_StandardFunctionObjectXMLConverters.hpp
Go to the documentation of this file.
1
// @HEADER
2
// ***********************************************************************
3
//
4
// Teuchos: Common Tools Package
5
// Copyright (2004) Sandia Corporation
6
//
7
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8
// license for use of this work by or on behalf of the U.S. Government.
9
//
10
// Redistribution and use in source and binary forms, with or without
11
// modification, are permitted provided that the following conditions are
12
// met:
13
//
14
// 1. Redistributions of source code must retain the above copyright
15
// notice, this list of conditions and the following disclaimer.
16
//
17
// 2. Redistributions in binary form must reproduce the above copyright
18
// notice, this list of conditions and the following disclaimer in the
19
// documentation and/or other materials provided with the distribution.
20
//
21
// 3. Neither the name of the Corporation nor the names of the
22
// contributors may be used to endorse or promote products derived from
23
// this software without specific prior written permission.
24
//
25
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
//
37
// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38
//
39
// ***********************************************************************
40
// @HEADER
41
42
#ifndef TEUCHOS_STANDARDFUNCTIONOBJECTXMLCONVERTERS_HPP
43
#define TEUCHOS_STANDARDFUNCTIONOBJECTXMLCONVERTERS_HPP
44
48
49
50
#include "
Teuchos_FunctionObjectXMLConverter.hpp
"
51
#include "Teuchos_StandardFunctionObjects.hpp"
52
53
54
namespace
Teuchos
{
55
56
58
template
<
class
OperandType>
59
class
SimpleFunctionXMLConverter
:
public
FunctionObjectXMLConverter
{
60
61
public
:
62
65
72
virtual
RCP<SimpleFunctionObject<OperandType>
>
73
getSpecificSimpleFunction
(OperandType operand)
const
= 0;
74
82
virtual
void
getSpecialSimpleFunctionXMLTraits
(
83
const
RCP
<
const
SimpleFunctionObject<OperandType>
>
/* functionObject */
,
84
XMLObject
&
/* xmlObj */
)
const
{}
85
87
90
92
RCP<FunctionObject>
93
convertXML
(
const
XMLObject
& xmlObj)
const
;
94
96
void
convertFunctionObject
(
97
const
RCP<const FunctionObject>
functionObject,
98
XMLObject
& xmlObj)
const
;
99
101
103
104
105
static
std::string getOperandAttributeName(){
106
static
const
std::string operandAttributeName =
"operand"
;
107
return
operandAttributeName;
108
}
109
111
112
};
113
114
template
<
class
OperandType>
115
RCP<FunctionObject>
116
SimpleFunctionXMLConverter<OperandType>::convertXML
(
117
const
XMLObject
& xmlObj)
const
118
{
119
OperandType operand =
120
xmlObj.
getRequired
<OperandType>(getOperandAttributeName());
121
return
getSpecificSimpleFunction
(operand);
122
}
123
124
template
<
class
OperandType>
125
void
SimpleFunctionXMLConverter<OperandType>::convertFunctionObject
(
126
const
RCP<const FunctionObject>
functionObject,
127
XMLObject
& xmlObj)
const
128
{
129
RCP<const SimpleFunctionObject<OperandType>
> castedFunction =
130
rcp_dynamic_cast<const SimpleFunctionObject<OperandType>
>(
131
functionObject,
true
);
132
OperandType operand = castedFunction->getModifiyingOperand();
133
xmlObj.
addAttribute
(getOperandAttributeName(),operand);
134
getSpecialSimpleFunctionXMLTraits
(castedFunction, xmlObj);
135
}
136
145
template
<
class
OperandType>
146
class
SubtractionFunctionXMLConverter
:
147
public
SimpleFunctionXMLConverter
<OperandType>
148
{
149
public
:
150
153
155
RCP<SimpleFunctionObject<OperandType>
>
156
getSpecificSimpleFunction
(OperandType operand)
const
;
157
159
};
160
161
template
<
class
OperandType>
162
RCP<SimpleFunctionObject<OperandType>
>
163
SubtractionFunctionXMLConverter<OperandType>::getSpecificSimpleFunction
(
164
OperandType operand)
const
165
{
166
return
rcp
(
new
SubtractionFunction<OperandType>
(operand));
167
}
168
177
template
<
class
OperandType>
178
class
AdditionFunctionXMLConverter
:
179
public
SimpleFunctionXMLConverter
<OperandType>
180
{
181
public
:
182
185
187
RCP<SimpleFunctionObject<OperandType>
>
188
getSpecificSimpleFunction
(OperandType operand)
const
;
189
191
};
192
193
template
<
class
OperandType>
194
RCP<SimpleFunctionObject<OperandType>
>
195
AdditionFunctionXMLConverter<OperandType>::getSpecificSimpleFunction
(
196
OperandType operand)
const
197
{
198
return
rcp
(
new
AdditionFunction<OperandType>
(operand));
199
}
200
209
template
<
class
OperandType>
210
class
MultiplicationFunctionXMLConverter
:
211
public
SimpleFunctionXMLConverter
<OperandType>
212
{
213
public
:
214
217
219
RCP<SimpleFunctionObject<OperandType>
>
220
getSpecificSimpleFunction
(OperandType operand)
const
;
221
223
};
224
225
template
<
class
OperandType>
226
RCP<SimpleFunctionObject<OperandType>
>
227
MultiplicationFunctionXMLConverter<OperandType>::getSpecificSimpleFunction
(
228
OperandType operand)
const
229
{
230
return
rcp
(
new
MultiplicationFunction<OperandType>
(operand));
231
}
232
241
template
<
class
OperandType>
242
class
DivisionFunctionXMLConverter
:
243
public
SimpleFunctionXMLConverter
<OperandType>
244
{
245
public
:
246
249
251
RCP<SimpleFunctionObject<OperandType>
>
252
getSpecificSimpleFunction
(OperandType operand)
const
;
253
255
};
256
257
template
<
class
OperandType>
258
RCP<SimpleFunctionObject<OperandType>
>
259
DivisionFunctionXMLConverter<OperandType>::getSpecificSimpleFunction
(
260
OperandType operand)
const
261
{
262
return
rcp
(
new
DivisionFunction<OperandType>
(operand));
263
}
264
265
266
}
// namespace Teuchos
267
268
269
#endif
// TEUCHOS_STANDARDFUNCTIONOBJECTXMLCONVERTERS_HPP
270
Teuchos_FunctionObjectXMLConverter.hpp
Converts back and forth between XML and FunctionObjects.
Teuchos::AdditionFunctionXMLConverter
Class for converting AdditionFunction objects to and from XML.
Definition
Teuchos_StandardFunctionObjectXMLConverters.hpp:180
Teuchos::AdditionFunctionXMLConverter::getSpecificSimpleFunction
RCP< SimpleFunctionObject< OperandType > > getSpecificSimpleFunction(OperandType operand) const
Definition
Teuchos_StandardFunctionObjectXMLConverters.hpp:195
Teuchos::AdditionFunction
A simple function object that adds a specififed value from the given arguement in the runFunction fun...
Definition
Teuchos_StandardFunctionObjects.hpp:198
Teuchos::DivisionFunctionXMLConverter
Class for converting DivisionFunction objects to and from XML.
Definition
Teuchos_StandardFunctionObjectXMLConverters.hpp:244
Teuchos::DivisionFunctionXMLConverter::getSpecificSimpleFunction
RCP< SimpleFunctionObject< OperandType > > getSpecificSimpleFunction(OperandType operand) const
Definition
Teuchos_StandardFunctionObjectXMLConverters.hpp:259
Teuchos::DivisionFunction
A simple function object that divides a specififed value from the given arguement in the runFunction ...
Definition
Teuchos_StandardFunctionObjects.hpp:317
Teuchos::FunctionObjectXMLConverter
An abstract base class for converting FunctionObjects to and from XML.
Definition
Teuchos_FunctionObjectXMLConverter.hpp:64
Teuchos::MultiplicationFunctionXMLConverter
Class for converting MultiplicationFunction objects to and from XML.
Definition
Teuchos_StandardFunctionObjectXMLConverters.hpp:212
Teuchos::MultiplicationFunctionXMLConverter::getSpecificSimpleFunction
RCP< SimpleFunctionObject< OperandType > > getSpecificSimpleFunction(OperandType operand) const
Definition
Teuchos_StandardFunctionObjectXMLConverters.hpp:227
Teuchos::MultiplicationFunction
A simple function object that multiplys a specififed value from the given arguement in the runFunctio...
Definition
Teuchos_StandardFunctionObjects.hpp:257
Teuchos::RCP
Smart reference counting pointer class for automatic garbage collection.
Definition
Teuchos_RCPDecl.hpp:429
Teuchos::RCP::rcp_dynamic_cast
RCP< T2 > rcp_dynamic_cast(const RCP< T1 > &p1, bool throw_on_fail=false)
Dynamic cast of underlying RCP type from T1* to T2*.
Teuchos::SimpleFunctionObject
A simple function object that applies a given operand to a spcified arguement using a specific operat...
Definition
Teuchos_StandardFunctionObjects.hpp:60
Teuchos::SimpleFunctionXMLConverter
An xml converter for SimpleFunctionObjects.
Definition
Teuchos_StandardFunctionObjectXMLConverters.hpp:59
Teuchos::SimpleFunctionXMLConverter::getSpecialSimpleFunctionXMLTraits
virtual void getSpecialSimpleFunctionXMLTraits(const RCP< const SimpleFunctionObject< OperandType > >, XMLObject &) const
Add and extra XML traits that are specific to a certain FuncitonOjbect when converting that function ...
Definition
Teuchos_StandardFunctionObjectXMLConverters.hpp:82
Teuchos::SimpleFunctionXMLConverter::convertXML
RCP< FunctionObject > convertXML(const XMLObject &xmlObj) const
Definition
Teuchos_StandardFunctionObjectXMLConverters.hpp:116
Teuchos::SimpleFunctionXMLConverter::getSpecificSimpleFunction
virtual RCP< SimpleFunctionObject< OperandType > > getSpecificSimpleFunction(OperandType operand) const =0
Gets the specific SimpleFunction to be returned by this converter when converting from XML.
Teuchos::SimpleFunctionXMLConverter::convertFunctionObject
void convertFunctionObject(const RCP< const FunctionObject > functionObject, XMLObject &xmlObj) const
Definition
Teuchos_StandardFunctionObjectXMLConverters.hpp:125
Teuchos::SubtractionFunctionXMLConverter
Class for converting SubtractionFunction objects to and from XML.
Definition
Teuchos_StandardFunctionObjectXMLConverters.hpp:148
Teuchos::SubtractionFunctionXMLConverter::getSpecificSimpleFunction
RCP< SimpleFunctionObject< OperandType > > getSpecificSimpleFunction(OperandType operand) const
Definition
Teuchos_StandardFunctionObjectXMLConverters.hpp:163
Teuchos::SubtractionFunction
A simple function object that subtracts a specififed value from the given arguement in the runFunctio...
Definition
Teuchos_StandardFunctionObjects.hpp:139
Teuchos::XMLObject
Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object,...
Definition
Teuchos_XMLObject.hpp:62
Teuchos::XMLObject::getRequired
const std::string & getRequired(const std::string &name) const
Get an attribute, throwing an std::exception if it is not found.
Definition
Teuchos_XMLObject.cpp:93
Teuchos::XMLObject::addAttribute
void addAttribute(const std::string &name, T value)
Lookup whether or not Doubles are allowed.
Definition
Teuchos_XMLObject.hpp:193
Teuchos
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
Teuchos::rcp
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
Definition
Teuchos_RCPDecl.hpp:1266
Generated by
1.17.0