Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos_ConditionXMLConverterDB.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
12#include "Teuchos_StaticSetupMacro.hpp"
13
14
15
16namespace Teuchos {
17
18
22 getConverterMap().insert(
23 ConverterPair(condition->getTypeAttributeValue(), converterToAdd));
24}
25
26
29 ConverterMap::const_iterator it =
30 getConverterMap().find(condition.getTypeAttributeValue());
31 TEUCHOS_TEST_FOR_EXCEPTION(it == getConverterMap().end(),
33 "Could not find a ConditionXMLConverter for a condition of type " <<
34 condition.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 conditionType = xmlObject.getRequired(
46 ConverterMap::const_iterator it = getConverterMap().find(conditionType);
47 TEUCHOS_TEST_FOR_EXCEPTION(it == getConverterMap().end(),
49 "Could not find a ConditionXMLConverter for a condition of type " <<
50 conditionType << " when reading in a condition from " <<
51 "xml." << std::endl << std::endl
52 )
53 return it->second;
54}
55
62
70
71ConditionXMLConverterDB::ConverterMap&
72ConditionXMLConverterDB::getConverterMap()
73{
74 static ConverterMap masterMap;
75 return masterMap;
76}
77
78
79} // namespace Teuchos
80
81
82namespace {
83
84
85TEUCHOS_STATIC_SETUP()
86{
90 TEUCHOS_ADD_NUMBERCONDITION_CONVERTER(unsigned short int);
95
97 TEUCHOS_ADD_NUMBERCONDITION_CONVERTER(unsigned long long int);
98
101 getDummyObject(),
102 Teuchos::rcp(new Teuchos::StringConditionConverter));
103
106 getDummyObject(),
107 Teuchos::rcp(new Teuchos::BoolConditionConverter));
108
111 getDummyObject(),
112 Teuchos::rcp(new Teuchos::OrConditionConverter));
113
116 getDummyObject(),
117 Teuchos::rcp(new Teuchos::AndConditionConverter));
118
121 getDummyObject(),
122 Teuchos::rcp(new Teuchos::EqualsConditionConverter));
123
126 getDummyObject(),
127 Teuchos::rcp(new Teuchos::NotConditionConverter));
128}
129
130
131} // namespace
A database for ConditionXMLConverters.
#define TEUCHOS_ADD_NUMBERCONDITION_CONVERTER(T)
Adds a NumberCondition of type T.
A collection of Exceptions thrown when converting Conditions to and from XML.
Thrown when an appropriate Condition Converter can't be found.
static RCP< const ConditionXMLConverter > getConverter(const Condition &condition)
Get an appropriate ConditionXMLConverter given a Condition.
static RCP< Condition > convertXML(const XMLObject &xmlObject, const XMLParameterListReader::EntryIDsMap &entryIDsMap)
Given an XMLObject and IDtoConditionMap, converts the XMLObject to a Condition.
static void addConverter(RCP< const Condition > condition, RCP< ConditionXMLConverter > converterToAdd)
Add a converter to the database.
static XMLObject convertCondition(RCP< const Condition > condition, const XMLParameterListWriter::EntryIDsMap &entryIDsMap)
Given a condition and ConditiontoIDMap, converts the condition to XML.
static const std::string & getTypeAttributeName()
Returns the string to be used for the type attribute.
A Condition determines whether or not a particular set of conditions are currently occuring.
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,...
std::map< ParameterEntry::ParameterEntryID, RCP< ParameterEntry > > EntryIDsMap
Convenience typedef.
std::map< RCP< const ParameterEntry >, ParameterEntry::ParameterEntryID, RCPConstComp > EntryIDsMap
#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,...
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.