Teuchos - Trilinos Tools Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_DependencyXMLConverterDB.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_DEPENDENCYXMLCONVERTERDB_HPP
11 #define TEUCHOS_DEPENDENCYXMLCONVERTERDB_HPP
12 
17 //Must include this and not just DependencyXMLConverter.hpp
18 //because of convience macros
20 //Once again, done for the macros.
23 
24 
25 namespace Teuchos {
26 
27 class Dependency;
28 
31 class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT DependencyXMLConverterDB {
32 public:
33 
36 
43  static void addConverter(RCP<const Dependency> dependency,
44  RCP<DependencyXMLConverter> converterToAdd);
45 
47 
50 
57  static RCP<const DependencyXMLConverter> getConverter(
58  const Dependency& dependency);
59 
65  getConverter(const XMLObject& xmlObject);
66 
79  static XMLObject convertDependency(
80  RCP<const Dependency> dependency,
81  const XMLParameterListWriter::EntryIDsMap& entryIDsMap,
82  ValidatortoIDMap& validatorIDsMap);
83 
96  static RCP<Dependency> convertXML(
97  const XMLObject& xmlObject,
98  const XMLParameterListReader::EntryIDsMap& entryIDsMap,
99  const IDtoValidatorMap& validatorIDsMap);
100 
102 
105 
111  static void printKnownConverters(std::ostream& out){
112  out << "Known DependencyXMLConverters: " << std::endl;
113  for(
114  ConverterMap::const_iterator it = getConverterMap().begin();
115  it != getConverterMap().end();
116  ++it)
117  {
118  out << "\t" << it->first <<std::endl;
119  }
120  }
121 
123 
124 private:
125 
128 
130  typedef std::map<std::string, RCP<DependencyXMLConverter> > ConverterMap;
131 
133  typedef std::pair<std::string, RCP<DependencyXMLConverter> >
134  ConverterPair;
135 
139  static ConverterMap& getConverterMap();
140 
142 
143 };
144 
145 } // end namespace Teuchos
146 
147 
148 //
149 // Helper Macros
150 //
151 
156 #define TEUCHOS_ADD_DEP_CONVERTER(DEP_TYPE, CONVERTER) \
157  Teuchos::DependencyXMLConverterDB::addConverter( \
158  Teuchos::DummyObjectGetter< DEP_TYPE >:: \
159  getDummyObject(), \
160  Teuchos::rcp(new CONVERTER));
161 
168 #define TEUCHOS_ADD_TEMPLATED_NUMBER_DEPS(T) \
169  TEUCHOS_ADD_NUMBER_VISUAL_DEP(T); \
170  TEUCHOS_ADD_RANGE_VALIDATOR_DEP(T); \
171  TEUCHOS_ADD_ARRAY_MODIFIER_DEP_GROUP(T);
172 
177 #define TEUCHOS_ADD_NUMBER_VISUAL_DEP(T) \
178  Teuchos::DependencyXMLConverterDB::addConverter( \
179  Teuchos::DummyObjectGetter<Teuchos::NumberVisualDependency< T > >:: \
180  getDummyObject(), \
181  Teuchos::rcp(new Teuchos::NumberVisualDependencyXMLConverter< T >));
182 
187 #define TEUCHOS_ADD_RANGE_VALIDATOR_DEP(T) \
188  Teuchos::DependencyXMLConverterDB::addConverter( \
189  Teuchos::DummyObjectGetter<Teuchos::RangeValidatorDependency< T > >:: \
190  getDummyObject(), \
191  Teuchos::rcp(new Teuchos::RangeValidatorDependencyXMLConverter< T >));
192 
196 #define TEUCHOS_ADD_NUMBER_ARRAY_LENGTH_DEP(DEPENDEE_TYPE , DEPENDENT_TYPE) \
197  Teuchos::DependencyXMLConverterDB::addConverter( \
198  Teuchos::DummyObjectGetter<Teuchos::NumberArrayLengthDependency< \
199  DEPENDEE_TYPE , DEPENDENT_TYPE > >::getDummyObject(), \
200  Teuchos::rcp(new Teuchos::NumberArrayLengthDependencyXMLConverter< \
201  DEPENDEE_TYPE , DEPENDENT_TYPE >));
202 
207 #define TEUCHOS_ADD_TWODROW_DEP(DEPENDEE_TYPE , DEPENDENT_TYPE) \
208  Teuchos::DependencyXMLConverterDB::addConverter( \
209  Teuchos::DummyObjectGetter<Teuchos::TwoDRowDependency< \
210  DEPENDEE_TYPE , DEPENDENT_TYPE > >::getDummyObject(), \
211  Teuchos::rcp(new Teuchos::TwoDRowDependencyXMLConverter< \
212  DEPENDEE_TYPE , DEPENDENT_TYPE >));
213 
217 #define TEUCHOS_ADD_TWODCOL_DEP(DEPENDEE_TYPE , DEPENDENT_TYPE) \
218  Teuchos::DependencyXMLConverterDB::addConverter( \
219  Teuchos::DummyObjectGetter<Teuchos::TwoDColDependency< \
220  DEPENDEE_TYPE , DEPENDENT_TYPE > >::getDummyObject(), \
221  Teuchos::rcp(new Teuchos::TwoDColDependencyXMLConverter< \
222  DEPENDEE_TYPE , DEPENDENT_TYPE >));
223 
228 #define TEUCHOS_ADD_ARRAY_MODIFIER_DEP_GROUP(DEPENDEE_TYPE) \
229  TEUCHOS_ADD_NUMBER_ARRAY_LENGTH_DEP( DEPENDEE_TYPE , std::string) \
230  TEUCHOS_ADD_NUMBER_ARRAY_LENGTH_DEP( DEPENDEE_TYPE , int) \
231  TEUCHOS_ADD_NUMBER_ARRAY_LENGTH_DEP( DEPENDEE_TYPE , long long int) \
232  TEUCHOS_ADD_NUMBER_ARRAY_LENGTH_DEP( DEPENDEE_TYPE , double) \
233  TEUCHOS_ADD_NUMBER_ARRAY_LENGTH_DEP( DEPENDEE_TYPE , float) \
234  TEUCHOS_ADD_TWODROW_DEP( DEPENDEE_TYPE , std::string) \
235  TEUCHOS_ADD_TWODROW_DEP( DEPENDEE_TYPE , int) \
236  TEUCHOS_ADD_TWODROW_DEP( DEPENDEE_TYPE , long long int) \
237  TEUCHOS_ADD_TWODROW_DEP( DEPENDEE_TYPE , double) \
238  TEUCHOS_ADD_TWODROW_DEP( DEPENDEE_TYPE , float) \
239  TEUCHOS_ADD_TWODCOL_DEP( DEPENDEE_TYPE , std::string) \
240  TEUCHOS_ADD_TWODCOL_DEP( DEPENDEE_TYPE , int) \
241  TEUCHOS_ADD_TWODCOL_DEP( DEPENDEE_TYPE , long long int) \
242  TEUCHOS_ADD_TWODCOL_DEP( DEPENDEE_TYPE , double) \
243  TEUCHOS_ADD_TWODCOL_DEP( DEPENDEE_TYPE , float)
244 
245 
246 #endif // TEUCHOS_DEPENDENCYXMLCONVERTERDB_HPP
Writes an XML object to a parameter list.
Provides ability to lookup DependencyXMLConverterDB.
Maps Validators to integers.
This class represents a depndency between elements in a Parameter List.
static void printKnownConverters(std::ostream &out)
prints the xml tags associated with all known converters
Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object...
A collection of standard DependencyXMLConverters.
std::map< RCP< const ParameterEntry >, ParameterEntry::ParameterEntryID, RCPConstComp > EntryIDsMap
A class for mapping validators to integers.
A collection of standard dependencies.
std::map< ParameterEntry::ParameterEntryID, RCP< ParameterEntry > > EntryIDsMap
Convenience typedef.
Smart reference counting pointer class for automatic garbage collection.