Teuchos Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
Teuchos_ValidatorXMLConverterDB.hpp
Go to the documentation of this file.
1// @HEADER
2// ***********************************************************************
3//
4// Teuchos: Common Tools Package
5// Copyright (2004) Sandia Corporation
6//
7// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8// license for use of this work by or on behalf of the U.S. Government.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38//
39// ***********************************************************************
40// @HEADER
41
42
43#ifndef TEUCHOS_VALIDATORXMLCONVERTERDB_HPP
44#define TEUCHOS_VALIDATORXMLCONVERTERDB_HPP
45
51
52
53namespace Teuchos {
54
55class ParameterEntryValidator;
56
60public:
61
64
71 static void addConverter(RCP<const ParameterEntryValidator> validator,
72 RCP<ValidatorXMLConverter> converterToAdd);
73
75
78
85 static RCP<const ValidatorXMLConverter> getConverter(
86 const ParameterEntryValidator& validator);
87
93 getConverter(const XMLObject& xmlObject);
94
108 static XMLObject convertValidator(
110 const ValidatortoIDMap& validatorIDsMap,
111 bool assignedID=true);
112
123 convertXML(
124 const XMLObject& xmlObject,
125 const IDtoValidatorMap& validatorIDsMap);
126
128
131
137 static void printKnownConverters(std::ostream& out);
138
140
141private:
142
145
147 typedef std::map<std::string, RCP<ValidatorXMLConverter> > ConverterMap;
148
150 typedef std::pair<std::string, RCP<ValidatorXMLConverter> > ConverterPair;
151
153
156
162 static ConverterMap& getConverterMap();
163
165
166
167};
168
169
170} // end namespace Teuchos
171
172
173//
174// Helper Macros
175//
176
177// Doing this include so that when people macros like
178// TEUCHOS_ADD_STRINGTOINTEGRALCONVERTER below they don't have to bother
179// including it themselves. More likely they might not even know they have
180// to.
182
186#define TEUCHOS_ADD_STRINGTOINTEGRALVALIDATOR_CONVERTER(INTEGRALTYPE) \
187 \
188 Teuchos::ValidatorXMLConverterDB::addConverter( \
189 Teuchos::DummyObjectGetter< \
190 Teuchos::StringToIntegralParameterEntryValidator< INTEGRALTYPE > >:: \
191 getDummyObject(), \
192 Teuchos::rcp(new Teuchos::StringToIntegralValidatorXMLConverter< INTEGRALTYPE >));
193
194
195
199#define TEUCHOS_ADD_ENHANCEDNUMBERVALIDATOR_CONVERTER(T) \
200 \
201 Teuchos::ValidatorXMLConverterDB::addConverter( \
202 Teuchos::DummyObjectGetter< \
203 Teuchos::EnhancedNumberValidator< T > >:: \
204 getDummyObject(), \
205 Teuchos::rcp(new Teuchos::EnhancedNumberValidatorXMLConverter< T >));
206
207
211#define TEUCHOS_ADD_ARRAYVALIDATOR_CONVERTER(VALIDATORTYPE, ENTRYTYPE) \
212 \
213 Teuchos::ValidatorXMLConverterDB::addConverter( \
214 Teuchos::DummyObjectGetter< \
215 Teuchos::ArrayValidator< VALIDATORTYPE, ENTRYTYPE > >:: \
216 getDummyObject(), \
217 Teuchos::rcp(new Teuchos::ArrayValidatorXMLConverter< VALIDATORTYPE, ENTRYTYPE >)); \
218 Teuchos::ValidatorXMLConverterDB::addConverter( \
219 Teuchos::DummyObjectGetter< \
220 Teuchos::TwoDArrayValidator< VALIDATORTYPE, ENTRYTYPE > >:: \
221 getDummyObject(), \
222 Teuchos::rcp(new Teuchos::TwoDArrayValidatorXMLConverter< VALIDATORTYPE, ENTRYTYPE >));
223
224
226#define TEUCHOS_ADD_NUMBERTYPE_VALIDATOR_CONVERTERS(T) \
227 TEUCHOS_ADD_STRINGTOINTEGRALVALIDATOR_CONVERTER(T); \
228 TEUCHOS_ADD_ENHANCEDNUMBERVALIDATOR_CONVERTER(T); \
229 TEUCHOS_ADD_ARRAYVALIDATOR_CONVERTER(Teuchos::EnhancedNumberValidator< T >, T );
230
234#define TEUCHOS_ADD_VALIDATOR_CONVERTER(VALIDATOR_TYPE, CONVERTER_TYPE) \
235 Teuchos::ValidatorXMLConverterDB::addConverter( \
236 Teuchos::DummyObjectGetter< VALIDATOR_TYPE > \
237 ::getDummyObject(), \
238 Teuchos::rcp(new CONVERTER_TYPE ));
239
240#endif // TEUCHOS_VALIDATORXMLCONVERTERDB_HPP
#define TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT
A collection of standard ValidatorXMLConverters.
Converts back and forth between XML and ParameterEntryValidators.
Maps Validators to integers.
Abstract interface for an object that can validate a ParameterEntry's value.
Smart reference counting pointer class for automatic garbage collection.
Provides ability to lookup ValidatorXMLConverterDB.
std::pair< std::string, RCP< ValidatorXMLConverter > > ConverterPair
convience typedef.
std::map< std::string, RCP< ValidatorXMLConverter > > ConverterMap
convience class.
A class for mapping validators to integers.
Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object,...