Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_ConditionXMLConverterDB.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 
20  RCP<const Condition> condition,
21  RCP<ConditionXMLConverter> converterToAdd){
22  getConverterMap().insert(
23  ConverterPair(condition->getTypeAttributeValue(), converterToAdd));
24 }
25 
26 
29  ConverterMap::const_iterator it =
30  getConverterMap().find(condition.getTypeAttributeValue());
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);
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 
57  RCP<const Condition> condition,
58  const XMLParameterListWriter::EntryIDsMap& entryIDsMap)
59 {
60  return getConverter(*condition)->fromConditiontoXML(condition, entryIDsMap);
61 }
62 
64  const XMLObject& xmlObject,
65  const XMLParameterListReader::EntryIDsMap& entryIDsMap)
66 {
67  return ConditionXMLConverterDB::getConverter(xmlObject)->
68  fromXMLtoCondition(xmlObject, entryIDsMap);
69 }
70 
73 {
74  static ConverterMap masterMap;
75  return masterMap;
76 }
77 
78 
79 } // namespace Teuchos
80 
81 
82 namespace {
83 
84 
86 {
90  TEUCHOS_ADD_NUMBERCONDITION_CONVERTER(unsigned short int);
92  TEUCHOS_ADD_NUMBERCONDITION_CONVERTER(unsigned long int);
95 
97  TEUCHOS_ADD_NUMBERCONDITION_CONVERTER(unsigned long long int);
98 
101  getDummyObject(),
103 
106  getDummyObject(),
108 
111  getDummyObject(),
113 
116  getDummyObject(),
118 
121  getDummyObject(),
123 
126  getDummyObject(),
128 }
129 
130 
131 } // namespace
An xml converter for StringConditions The valid XML represntation for a StringCondition is: ...
virtual std::string getTypeAttributeValue() const =0
Get the value that should be used for the condition type attribute when converting a condition to XML...
A collection of Exceptions thrown when converting Conditions to and from XML.
static RCP< Condition > convertXML(const XMLObject &xmlObject, const XMLParameterListReader::EntryIDsMap &entryIDsMap)
Given an XMLObject and IDtoConditionMap, converts the XMLObject to a Condition.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
Thrown when an appropriate Condition Converter can&#39;t be found.
static RCP< const ConditionXMLConverter > getConverter(const Condition &condition)
Get an appropriate ConditionXMLConverter given a Condition.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
std::pair< std::string, RCP< ConditionXMLConverter > > ConverterPair
convience typedef.
std::map< std::string, RCP< ConditionXMLConverter > > ConverterMap
convience class.
Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object...
A database for ConditionXMLConverters.
std::map< RCP< const ParameterEntry >, ParameterEntry::ParameterEntryID, RCPConstComp > EntryIDsMap
std::map< ParameterEntry::ParameterEntryID, RCP< ParameterEntry > > EntryIDsMap
Convenience typedef.
static XMLObject convertCondition(RCP< const Condition > condition, const XMLParameterListWriter::EntryIDsMap &entryIDsMap)
Given a condition and ConditiontoIDMap, converts the condition to XML.
Class for retrieving a dummy object of type T.
A Condition determines whether or not a particular set of conditions are currently occuring...
#define TEUCHOS_ADD_NUMBERCONDITION_CONVERTER(T)
Adds a NumberCondition of type T.
static void addConverter(RCP< const Condition > condition, RCP< ConditionXMLConverter > converterToAdd)
Add a converter to the database.
Smart reference counting pointer class for automatic garbage collection.
static const std::string & getTypeAttributeName()
Returns the string to be used for the type attribute.
const std::string & getRequired(const std::string &name) const
Get an attribute, throwing an std::exception if it is not found.
TEUCHOS_STATIC_SETUP()
static ConverterMap & getConverterMap()
Gets the default converter to be used to convert Conditions.