Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_FunctionObjectXMLConverterDB.cpp
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 
13 
14 
15 
16 namespace Teuchos {
17 
18 
21  RCP<FunctionObjectXMLConverter> converterToAdd){
22  getConverterMap().insert(
23  ConverterPair(function->getTypeAttributeValue(), converterToAdd));
24 }
25 
26 
29  ConverterMap::const_iterator it =
30  getConverterMap().find(function.getTypeAttributeValue());
33  "Could not find a FunctionObjectXMLConverter for a FuncitonObject of type " <<
34  function.getTypeAttributeValue() << " when writing out a condition to " <<
35  "xml." << std::endl << std::endl
36  )
37  return it->second;
38 }
39 
40 
43 {
44  std::string functionType = xmlObject.getRequired(
46  ConverterMap::const_iterator it = getConverterMap().find(functionType);
49  "Could not find a FunctionObjectXMLConverter for a condition of type " <<
50  functionType << " when reading in a condition from " <<
51  "xml." << std::endl << std::endl
52  )
53  return it->second;
54 }
55 
58 {
59  return getConverter(*function)->fromFunctionObjecttoXML(function);
60 }
61 
63  const XMLObject& xmlObject)
64 {
66  fromXMLtoFunctionObject(xmlObject);
67 }
68 
71 {
72  static ConverterMap masterMap;
73  return masterMap;
74 }
75 
76 
77 } // namespace Teuchos
78 
79 
80 namespace {
81 
82 
84 {
85 
89  TEUCHOS_ADD_SIMPLEFUNCTIONCONVERTERS(unsigned short int);
91  TEUCHOS_ADD_SIMPLEFUNCTIONCONVERTERS(unsigned long int);
94 
96  TEUCHOS_ADD_SIMPLEFUNCTIONCONVERTERS(unsigned long long int);
97 
98 }
99 
100 
101 } // namespace
static XMLObject convertFunctionObject(RCP< const FunctionObject > function)
Given a FunctionObject, converts the FunctionObject to XML.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
std::pair< std::string, RCP< FunctionObjectXMLConverter > > ConverterPair
convience typedef.
#define TEUCHOS_ADD_SIMPLEFUNCTIONCONVERTERS(T)
Adds a SubtractionFunction, AdditionFunction, MultiplicationFunction, and DivisionFunction of type T ...
A database for FunctionObjectXMLConverters.
Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object...
Thrown when an appropriate FunctionObject Converter can&#39;t be found.
static ConverterMap & getConverterMap()
Gets the default converter to be used to convert FunctionObjects.
static void addConverter(RCP< const FunctionObject > function, RCP< FunctionObjectXMLConverter > converterToAdd)
Add a converter to the database.
Smart reference counting pointer class for automatic garbage collection.
static RCP< FunctionObject > convertXML(const XMLObject &xmlObject)
Given an XMLObject, converts the XMLObject to a FunctionObject.
static RCP< const FunctionObjectXMLConverter > getConverter(const FunctionObject &function)
Get an appropriate FunctionObjectXMLConverter given a FunctionObject.
A function object represents an arbitrary function.
std::map< std::string, RCP< FunctionObjectXMLConverter > > ConverterMap
convience class.
A collection of Exceptions thrown when converting FunctionObjects to and from XML.
const std::string & getRequired(const std::string &name) const
Get an attribute, throwing an std::exception if it is not found.
TEUCHOS_STATIC_SETUP()