Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_StandardFunctionObjectXMLConverters.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Teuchos: Common Tools Package
4 //
5 // Copyright 2004 NTESS and the Teuchos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef TEUCHOS_STANDARDFUNCTIONOBJECTXMLCONVERTERS_HPP
11 #define TEUCHOS_STANDARDFUNCTIONOBJECTXMLCONVERTERS_HPP
12 
20 
21 
22 namespace Teuchos {
23 
24 
26 template<class OperandType>
28 
29 public:
30 
33 
41  getSpecificSimpleFunction(OperandType operand) const = 0;
42 
51  const RCP<const SimpleFunctionObject<OperandType> > /* functionObject */,
52  XMLObject& /* xmlObj */) const{}
53 
55 
58 
61  convertXML(const XMLObject& xmlObj) const;
62 
65  const RCP<const FunctionObject> functionObject,
66  XMLObject& xmlObj) const;
67 
69 
71 
72 
73  static std::string getOperandAttributeName(){
74  static const std::string operandAttributeName = "operand";
75  return operandAttributeName;
76  }
77 
79 
80 };
81 
82 template<class OperandType>
83 RCP<FunctionObject>
85  const XMLObject& xmlObj) const
86 {
87  OperandType operand =
88  xmlObj.getRequired<OperandType>(getOperandAttributeName());
89  return getSpecificSimpleFunction(operand);
90 }
91 
92 template<class OperandType>
94  const RCP<const FunctionObject> functionObject,
95  XMLObject& xmlObj) const
96 {
98  rcp_dynamic_cast<const SimpleFunctionObject<OperandType> >(
99  functionObject, true);
100  OperandType operand = castedFunction->getModifiyingOperand();
101  xmlObj.addAttribute(getOperandAttributeName(),operand);
102  getSpecialSimpleFunctionXMLTraits(castedFunction, xmlObj);
103 }
104 
113 template<class OperandType>
115  public SimpleFunctionXMLConverter<OperandType>
116 {
117 public:
118 
121 
124  getSpecificSimpleFunction(OperandType operand) const;
125 
127 };
128 
129 template<class OperandType>
132  OperandType operand) const
133 {
134  return rcp(new SubtractionFunction<OperandType>(operand));
135 }
136 
145 template<class OperandType>
147  public SimpleFunctionXMLConverter<OperandType>
148 {
149 public:
150 
153 
156  getSpecificSimpleFunction(OperandType operand) const;
157 
159 };
160 
161 template<class OperandType>
164  OperandType operand) const
165 {
166  return rcp(new AdditionFunction<OperandType>(operand));
167 }
168 
177 template<class OperandType>
179  public SimpleFunctionXMLConverter<OperandType>
180 {
181 public:
182 
185 
188  getSpecificSimpleFunction(OperandType operand) const;
189 
191 };
192 
193 template<class OperandType>
196  OperandType operand) const
197 {
198  return rcp(new MultiplicationFunction<OperandType>(operand));
199 }
200 
209 template<class OperandType>
211  public SimpleFunctionXMLConverter<OperandType>
212 {
213 public:
214 
217 
220  getSpecificSimpleFunction(OperandType operand) const;
221 
223 };
224 
225 template<class OperandType>
228  OperandType operand) const
229 {
230  return rcp(new DivisionFunction<OperandType>(operand));
231 }
232 
233 
234 } // namespace Teuchos
235 
236 
237 #endif // TEUCHOS_STANDARDFUNCTIONOBJECTXMLCONVERTERS_HPP
238 
RCP< SimpleFunctionObject< OperandType > > getSpecificSimpleFunction(OperandType operand) const
RCP< SimpleFunctionObject< OperandType > > getSpecificSimpleFunction(OperandType operand) const
RCP< FunctionObject > convertXML(const XMLObject &xmlObj) const
A simple function object that multiplys a specififed value from the given arguement in the runFunctio...
Converts back and forth between XML and FunctionObjects.
A simple function object that adds a specififed value from the given arguement in the runFunction fun...
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 ...
Class for converting MultiplicationFunction objects to and from XML.
Class for converting SubtractionFunction objects to and from XML.
A simple function object that subtracts a specififed value from the given arguement in the runFunctio...
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
RCP< SimpleFunctionObject< OperandType > > getSpecificSimpleFunction(OperandType operand) const
Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object...
Class for converting DivisionFunction objects to and from XML.
Class for converting AdditionFunction objects to and from XML.
void addAttribute(const std::string &name, T value)
Lookup whether or not Doubles are allowed.
virtual RCP< SimpleFunctionObject< OperandType > > getSpecificSimpleFunction(OperandType operand) const =0
Gets the specific SimpleFunction to be returned by this converter when converting from XML...
void convertFunctionObject(const RCP< const FunctionObject > functionObject, XMLObject &xmlObj) const
An abstract base class for converting FunctionObjects to and from XML.
RCP< SimpleFunctionObject< OperandType > > getSpecificSimpleFunction(OperandType operand) const
A simple function object that divides a specififed value from the given arguement in the runFunction ...
Smart reference counting pointer class for automatic garbage collection.
const std::string & getRequired(const std::string &name) const
Get an attribute, throwing an std::exception if it is not found.
A simple function object that applies a given operand to a spcified arguement using a specific operat...