Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_StandardConditionXMLConverters.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_STANDARDCONDITIONXMLCONVERTERS_HPP
11 #define TEUCHOS_STANDARDCONDITIONXMLCONVERTERS_HPP
12 
20 
21 
22 namespace Teuchos {
23 
24 
28 
29 public:
30 
33 
42  Condition::ConstConditionList& conditions) const = 0;
43 
45 
48 
50  virtual RCP<Condition> convertXML(
51  const XMLObject& xmlObj,
52  const XMLParameterListReader::EntryIDsMap& entryIDsMap) const;
53 
55  void convertCondition(
56  const RCP<const Condition> condition,
57  XMLObject& xmlObj,
58  const XMLParameterListWriter::EntryIDsMap& entryIDsMap) const;
59 
61 
62 };
63 
74 
75 public:
76 
79 
82  Condition::ConstConditionList& conditions) const;
83 
85 
86 };
87 
98 
99 public:
100 
103 
106  Condition::ConstConditionList& conditions) const;
107 
109 
110 };
111 
112 
123 
124 public:
125 
128 
131  Condition::ConstConditionList& conditions) const;
132 
134 
135 };
136 
147 
148 public:
149 
152 
154  virtual RCP<Condition> convertXML(
155  const XMLObject& xmlObj,
156  const XMLParameterListReader::EntryIDsMap& entryIDsMap) const;
157 
159  void convertCondition(
160  const RCP<const Condition> condition,
161  XMLObject& xmlObj,
162  const XMLParameterListWriter::EntryIDsMap& entryIDsMap) const;
163 
165 
166 };
167 
171 
172 public:
173 
176 
185  virtual RCP<ParameterCondition> getSpecificParameterCondition(
186  const XMLObject& xmlObj,
187  RCP<ParameterEntry> parameterEntry) const = 0;
188 
196  virtual void addSpecificXMLTraits(
197  RCP<const ParameterCondition> condition, XMLObject& xmlObj) const = 0;
198 
200 
203 
205  virtual RCP<Condition> convertXML(
206  const XMLObject& xmlObj,
207  const XMLParameterListReader::EntryIDsMap& entryIDsMap) const;
208 
210  void convertCondition(
211  const RCP<const Condition> condition,
212  XMLObject& xmlObj,
213  const XMLParameterListWriter::EntryIDsMap& entryIDsMap) const;
214 
216 
217 private:
218 
221 
223  static const std::string& getParameterEntryIdAttributeName(){
224  static const std::string parameterEntryIdAttributeName = "parameterId";
225  return parameterEntryIdAttributeName;
226  }
227 
229 
230 };
231 
244 
245 public:
246 
249 
252  const XMLObject& xmlObj,
253  RCP<ParameterEntry> parameterEntry) const;
254 
257  RCP<const ParameterCondition> condition, XMLObject& xmlObj) const;
258 
260 
261 private:
262 
264  static const std::string& getValuesTagName(){
265  static const std::string valuesTagName = "Values";
266  return valuesTagName;
267  }
268 
270  static const std::string& getStringTagName(){
271  static const std::string stringTagName = "String";
272  return stringTagName;
273  }
274 
276  static const std::string& getStringValueAttributeName(){
277  static const std::string stringValueAttributeName = "value";
278  return stringValueAttributeName;
279  }
280 
281 
282 };
283 
292 
293 public:
294 
297 
300  const XMLObject& xmlObj,
301  RCP<ParameterEntry> parameterEntry) const;
302 
305  RCP<const ParameterCondition> condition, XMLObject& xmlObj) const;
306 
308 
309 };
310 
320 template<class T>
322 
323 public:
324 
327 
330  const XMLObject& xmlObj,
331  RCP<ParameterEntry> parameterEntry) const;
332 
335  RCP<const ParameterCondition> condition, XMLObject& xmlObj) const;
336 
338 
339 };
340 
341 template<class T>
344  const XMLObject& xmlObj,
345  RCP<ParameterEntry> parameterEntry) const
346 {
347  int functionTag = xmlObj.findFirstChild(FunctionObject::getXMLTagName());
348  if(functionTag == -1){
349  return rcp(new NumberCondition<T>(parameterEntry));
350  }
351  else{
352  RCP<FunctionObject> functionObj =
354  RCP<SimpleFunctionObject<T> > castedFunction =
355  rcp_dynamic_cast<SimpleFunctionObject<T> >(functionObj);
356  return rcp(new NumberCondition<T>(parameterEntry, castedFunction));
357  }
358 }
359 
360 template<class T>
362  RCP<const ParameterCondition> condition, XMLObject& xmlObj) const
363 {
364  RCP<const NumberCondition<T> > castedCondition =
365  rcp_dynamic_cast<const NumberCondition<T> >(condition);
366  RCP<const SimpleFunctionObject<T> > functionObject =
367  castedCondition->getFunctionObject();
368  if(!functionObject.is_null()){
369  XMLObject functionXML =
371  xmlObj.addChild(functionXML);
372  }
373 }
374 
375 
376 
377 } // namespace Teuchos
378 
379 
380 #endif // TEUCHOS_STANDARDCONDITIONXMLCONVERTERS_HPP
381 
void convertCondition(const RCP< const Condition > condition, XMLObject &xmlObj, const XMLParameterListWriter::EntryIDsMap &entryIDsMap) const
RCP< ParameterCondition > getSpecificParameterCondition(const XMLObject &xmlObj, RCP< ParameterEntry > parameterEntry) const
An xml converter for StringConditions The valid XML represntation for a StringCondition is: ...
virtual RCP< Condition > convertXML(const XMLObject &xmlObj, const XMLParameterListReader::EntryIDsMap &entryIDsMap) const
RCP< ParameterCondition > getSpecificParameterCondition(const XMLObject &xmlObj, RCP< ParameterEntry > parameterEntry) const
static XMLObject convertFunctionObject(RCP< const FunctionObject > function)
Given a FunctionObject, converts the FunctionObject to XML.
void addChild(const XMLObject &child)
Add a child node to the node.
RCP< BoolLogicCondition > getSpecificBoolLogicCondition(Condition::ConstConditionList &conditions) const
A Number Condition is a Parameter Condition that evaluates whether or not a number parameter is great...
A database for FunctionObjectXMLConverters.
Converts back and forth between XML and Dependencies.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
static const std::string & getParameterEntryIdAttributeName()
gets the ParameterEntryID attribute name.
Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object...
std::map< RCP< const ParameterEntry >, ParameterEntry::ParameterEntryID, RCPConstComp > EntryIDsMap
static const std::string & getXMLTagName()
Returns the name of the XML tag used to indicate a funciton object.
void convertCondition(const RCP< const Condition > condition, XMLObject &xmlObj, const XMLParameterListWriter::EntryIDsMap &entryIDsMap) const
An xml converter for NumberConditions The valid XML represntation for a NumberCondition is: ...
#define TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT
virtual RCP< BoolLogicCondition > getSpecificBoolLogicCondition(Condition::ConstConditionList &conditions) const =0
Gets the specific BoolLogicCondition to be returned by this conveter when converting from XML...
RCP< BoolLogicCondition > getSpecificBoolLogicCondition(Condition::ConstConditionList &conditions) const
std::map< ParameterEntry::ParameterEntryID, RCP< ParameterEntry > > EntryIDsMap
Convenience typedef.
An abstract base class for converting Dependencies to and from XML.
RCP< BoolLogicCondition > getSpecificBoolLogicCondition(Condition::ConstConditionList &conditions) const
void addSpecificXMLTraits(RCP< const ParameterCondition > condition, XMLObject &xmlObj) const
An xml converter for BoolLogicConditions.
Smart reference counting pointer class for automatic garbage collection.
void addSpecificXMLTraits(RCP< const ParameterCondition > condition, XMLObject &xmlObj) const
int findFirstChild(std::string tagName) const
Returns the index of the first child found with the given tag name. Returns -1 if no child is found...
static RCP< FunctionObject > convertXML(const XMLObject &xmlObject)
Given an XMLObject, converts the XMLObject to a FunctionObject.
RCP< ParameterCondition > getSpecificParameterCondition(const XMLObject &xmlObj, RCP< ParameterEntry > parameterEntry) const
const XMLObject & getChild(int i) const
Return the i-th child node.
void addSpecificXMLTraits(RCP< const ParameterCondition > condition, XMLObject &xmlObj) const
Standard Conditions to be used.
virtual RCP< Condition > convertXML(const XMLObject &xmlObj, const XMLParameterListReader::EntryIDsMap &entryIDsMap) const
Replacement for std::vector that is compatible with the Teuchos Memory Management classes...