Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_ParameterEntryXMLConverterDB.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_PARAMETERENTRYXMLCONVERTERDB_HPP
11 #define TEUCHOS_PARAMETERENTRYXMLCONVERTERDB_HPP
12 
16 
17 
23 namespace Teuchos {
24 
28 public:
29 
32 
37  static void addConverter(RCP<ParameterEntryXMLConverter> converterToAdd){
38  getConverterMap().insert(
39  ConverterPair(converterToAdd->getTypeAttributeValue(), converterToAdd));
40  }
41 
43 
46 
47 
53  getConverter(RCP<const ParameterEntry> entry);
54 
60  getConverter(const XMLObject& xmlObject);
61 
63  static RCP<const ParameterEntryXMLConverter> getDefaultConverter();
64 
66 
67  // 2010/07/30: rabarlt: The above two functions should be moved into
68  // Teuchos_ParameterEntryXMLConvergerDB.cpp. These functions don't need to
69  // be inlined and it will be easier to set breakpoints in the debugger if
70  // they are in a *.cpp file.
71 
74 
80  const std::string& name,
82  const ValidatortoIDMap& validatorIDsMap)
83  {
84  return getConverter(entry)->fromParameterEntrytoXML(
85  entry, name, id, validatorIDsMap);
86  }
87 
91  static ParameterEntry convertXML(const XMLObject& xmlObj)
92  {
93  return getConverter(xmlObj)->fromXMLtoParameterEntry(xmlObj);
94  }
95 
97 
100 
106  static void printKnownConverters(std::ostream& out);
108 
109 private:
110 
113 
115  typedef std::map<std::string, RCP<ParameterEntryXMLConverter> > ConverterMap;
116 
118  typedef std::pair<std::string, RCP<ParameterEntryXMLConverter> > ConverterPair;
119 
121 
123  static ConverterMap& getConverterMap();
124 
125 
126 };
127 
128 
129 } // namespace Teuchos
130 
131 //
132 // Helper Macros
133 //
134 
135 
139 #define TEUCHOS_ADD_TYPE_CONVERTER(T) \
140  \
141  Teuchos::ParameterEntryXMLConverterDB::addConverter( \
142  Teuchos::rcp(new Teuchos::StandardTemplatedParameterConverter< T >));
143 
147 #define TEUCHOS_ADD_ARRAYTYPE_CONVERTER(T) \
148  Teuchos::ParameterEntryXMLConverterDB::addConverter( \
149  Teuchos::rcp(new Teuchos::StandardTemplatedParameterConverter< Teuchos::Array< T > >)); \
150  Teuchos::ParameterEntryXMLConverterDB::addConverter( \
151  Teuchos::rcp(new Teuchos::StandardTemplatedParameterConverter< Teuchos::TwoDArray< T > >));
152 
156 #define TEUCHOS_ADD_TYPE_AND_ARRAYTYPE_CONVERTER(T) \
157  \
158  TEUCHOS_ADD_TYPE_CONVERTER(T); \
159  TEUCHOS_ADD_ARRAYTYPE_CONVERTER(T);
160 
161 
162 #endif // TEUCHOS_PARAMETERENTRYXMLCONVERTERDB_HPP
This object is held as the &quot;value&quot; in the Teuchos::ParameterList std::map.
A collection of standard ParameterEntryXMLConverters.
Provides ability to lookup ParameterEntryXMLConverters.
Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object...
Writes a ParameterList to an XML object.
std::pair< std::string, RCP< ParameterEntryXMLConverter > > ConverterPair
convience typedef
A class for mapping validators to integers.
std::map< std::string, RCP< ParameterEntryXMLConverter > > ConverterMap
convience typedef
#define TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT
static XMLObject convertEntry(RCP< const ParameterEntry > entry, const std::string &name, const ParameterEntry::ParameterEntryID &id, const ValidatortoIDMap &validatorIDsMap)
Converts the given ParameterEntry to XML.
static void addConverter(RCP< ParameterEntryXMLConverter > converterToAdd)
Add a converter to the database.
static ParameterEntry convertXML(const XMLObject &xmlObj)
Converts XML to a ParameterEntry.
A collection of Exceptions that can be potentially thrown when converting a ParameterList to and from...
Smart reference counting pointer class for automatic garbage collection.