Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos_FunctionObjectXMLConverterDB.cpp
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
11#include "Teuchos_StaticSetupMacro.hpp"
13
14
15
16namespace Teuchos {
17
18
22 getConverterMap().insert(
23 ConverterPair(function->getTypeAttributeValue(), converterToAdd));
24}
25
26
29 ConverterMap::const_iterator it =
30 getConverterMap().find(function.getTypeAttributeValue());
31 TEUCHOS_TEST_FOR_EXCEPTION(it == getConverterMap().end(),
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);
47 TEUCHOS_TEST_FOR_EXCEPTION(it == getConverterMap().end(),
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
61
68
69FunctionObjectXMLConverterDB::ConverterMap&
70FunctionObjectXMLConverterDB::getConverterMap()
71{
72 static ConverterMap masterMap;
73 return masterMap;
74}
75
76
77} // namespace Teuchos
78
79
80namespace {
81
82
83TEUCHOS_STATIC_SETUP()
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
A database for FunctionObjectXMLConverters.
#define TEUCHOS_ADD_SIMPLEFUNCTIONCONVERTERS(T)
Adds a SubtractionFunction, AdditionFunction, MultiplicationFunction, and DivisionFunction of type T ...
A collection of Exceptions thrown when converting FunctionObjects to and from XML.
Thrown when an appropriate FunctionObject Converter can't be found.
static RCP< const FunctionObjectXMLConverter > getConverter(const FunctionObject &function)
Get an appropriate FunctionObjectXMLConverter given a FunctionObject.
static void addConverter(RCP< const FunctionObject > function, RCP< FunctionObjectXMLConverter > converterToAdd)
Add a converter to the database.
static XMLObject convertFunctionObject(RCP< const FunctionObject > function)
Given a FunctionObject, converts the FunctionObject to XML.
static RCP< FunctionObject > convertXML(const XMLObject &xmlObject)
Given an XMLObject, converts the XMLObject to a FunctionObject.
A function object represents an arbitrary function.
Smart reference counting pointer class for automatic garbage collection.
Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object,...
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...