Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_ValidatorXMLConverterDB.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_VALIDATORXMLCONVERTERDB_HPP
11 #define TEUCHOS_VALIDATORXMLCONVERTERDB_HPP
12 
18 
19 
20 namespace Teuchos {
21 
22 class ParameterEntryValidator;
23 
27 public:
28 
31 
38  static void addConverter(RCP<const ParameterEntryValidator> validator,
39  RCP<ValidatorXMLConverter> converterToAdd);
40 
42 
45 
52  static RCP<const ValidatorXMLConverter> getConverter(
53  const ParameterEntryValidator& validator);
54 
60  getConverter(const XMLObject& xmlObject);
61 
75  static XMLObject convertValidator(
77  const ValidatortoIDMap& validatorIDsMap,
78  bool assignedID=true);
79 
90  convertXML(
91  const XMLObject& xmlObject,
92  const IDtoValidatorMap& validatorIDsMap);
93 
95 
98 
104  static void printKnownConverters(std::ostream& out);
105 
107 
108 private:
109 
112 
114  typedef std::map<std::string, RCP<ValidatorXMLConverter> > ConverterMap;
115 
117  typedef std::pair<std::string, RCP<ValidatorXMLConverter> > ConverterPair;
118 
120 
123 
129  static ConverterMap& getConverterMap();
130 
132 
133 
134 };
135 
136 
137 } // end namespace Teuchos
138 
139 
140 //
141 // Helper Macros
142 //
143 
144 // Doing this include so that when people macros like
145 // TEUCHOS_ADD_STRINGTOINTEGRALCONVERTER below they don't have to bother
146 // including it themselves. More likely they might not even know they have
147 // to.
149 
153 #define TEUCHOS_ADD_STRINGTOINTEGRALVALIDATOR_CONVERTER(INTEGRALTYPE) \
154  \
155  Teuchos::ValidatorXMLConverterDB::addConverter( \
156  Teuchos::DummyObjectGetter< \
157  Teuchos::StringToIntegralParameterEntryValidator< INTEGRALTYPE > >:: \
158  getDummyObject(), \
159  Teuchos::rcp(new Teuchos::StringToIntegralValidatorXMLConverter< INTEGRALTYPE >));
160 
161 
162 
166 #define TEUCHOS_ADD_ENHANCEDNUMBERVALIDATOR_CONVERTER(T) \
167  \
168  Teuchos::ValidatorXMLConverterDB::addConverter( \
169  Teuchos::DummyObjectGetter< \
170  Teuchos::EnhancedNumberValidator< T > >:: \
171  getDummyObject(), \
172  Teuchos::rcp(new Teuchos::EnhancedNumberValidatorXMLConverter< T >));
173 
174 
178 #define TEUCHOS_ADD_ARRAYVALIDATOR_CONVERTER(VALIDATORTYPE, ENTRYTYPE) \
179  \
180  Teuchos::ValidatorXMLConverterDB::addConverter( \
181  Teuchos::DummyObjectGetter< \
182  Teuchos::ArrayValidator< VALIDATORTYPE, ENTRYTYPE > >:: \
183  getDummyObject(), \
184  Teuchos::rcp(new Teuchos::ArrayValidatorXMLConverter< VALIDATORTYPE, ENTRYTYPE >)); \
185  Teuchos::ValidatorXMLConverterDB::addConverter( \
186  Teuchos::DummyObjectGetter< \
187  Teuchos::TwoDArrayValidator< VALIDATORTYPE, ENTRYTYPE > >:: \
188  getDummyObject(), \
189  Teuchos::rcp(new Teuchos::TwoDArrayValidatorXMLConverter< VALIDATORTYPE, ENTRYTYPE >));
190 
191 
193 #define TEUCHOS_ADD_NUMBERTYPE_VALIDATOR_CONVERTERS(T) \
194  TEUCHOS_ADD_STRINGTOINTEGRALVALIDATOR_CONVERTER(T); \
195  TEUCHOS_ADD_ENHANCEDNUMBERVALIDATOR_CONVERTER(T); \
196  TEUCHOS_ADD_ARRAYVALIDATOR_CONVERTER(Teuchos::EnhancedNumberValidator< T >, T );
197 
201 #define TEUCHOS_ADD_VALIDATOR_CONVERTER(VALIDATOR_TYPE, CONVERTER_TYPE) \
202  Teuchos::ValidatorXMLConverterDB::addConverter( \
203  Teuchos::DummyObjectGetter< VALIDATOR_TYPE > \
204  ::getDummyObject(), \
205  Teuchos::rcp(new CONVERTER_TYPE ));
206 
207 #endif // TEUCHOS_VALIDATORXMLCONVERTERDB_HPP
Provides ability to lookup ValidatorXMLConverterDB.
A collection of standard ValidatorXMLConverters.
Maps Validators to integers.
Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object...
Converts back and forth between XML and ParameterEntryValidators.
A class for mapping validators to integers.
std::pair< std::string, RCP< ValidatorXMLConverter > > ConverterPair
convience typedef.
#define TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT
Abstract interface for an object that can validate a ParameterEntry&#39;s value.
std::map< std::string, RCP< ValidatorXMLConverter > > ConverterMap
convience class.
Smart reference counting pointer class for automatic garbage collection.