Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos_ParameterEntryXMLConverterDB.hpp
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
23namespace Teuchos {
24
27class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT ParameterEntryXMLConverterDB {
28public:
29
32
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,
83 {
84 return getConverter(entry)->fromParameterEntrytoXML(
85 entry, name, id, validatorIDsMap);
86 }
87
92 {
93 return getConverter(xmlObj)->fromXMLtoParameterEntry(xmlObj);
94 }
95
97
100
106 static void printKnownConverters(std::ostream& out);
108
109private:
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
A collection of standard ParameterEntryXMLConverters.
A collection of Exceptions that can be potentially thrown when converting a ParameterList to and from...
Writes a ParameterList to an XML object.
Provides ability to lookup ParameterEntryXMLConverters.
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.
This object is held as the "value" in the Teuchos::ParameterList std::map.
Smart reference counting pointer class for automatic garbage collection.
A class for mapping validators to integers.
Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object,...
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...