Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos_StandardConditionXMLConverters.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#ifndef TEUCHOS_STANDARDCONDITIONXMLCONVERTERS_HPP
43#define TEUCHOS_STANDARDCONDITIONXMLCONVERTERS_HPP
44
52
53
54namespace Teuchos {
55
56
60
61public:
62
65
74 Condition::ConstConditionList& conditions) const = 0;
75
77
80
83 const XMLObject& xmlObj,
84 const XMLParameterListReader::EntryIDsMap& entryIDsMap) const;
85
88 const RCP<const Condition> condition,
89 XMLObject& xmlObj,
90 const XMLParameterListWriter::EntryIDsMap& entryIDsMap) const;
91
93
94};
95
106
107public:
108
111
114 Condition::ConstConditionList& conditions) const;
115
117
118};
119
130
131public:
132
135
138 Condition::ConstConditionList& conditions) const;
139
141
142};
143
144
155
156public:
157
160
163 Condition::ConstConditionList& conditions) const;
164
166
167};
168
179
180public:
181
184
187 const XMLObject& xmlObj,
188 const XMLParameterListReader::EntryIDsMap& entryIDsMap) const;
189
191 void convertCondition(
192 const RCP<const Condition> condition,
193 XMLObject& xmlObj,
194 const XMLParameterListWriter::EntryIDsMap& entryIDsMap) const;
195
197
198};
199
202class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT ParameterConditionConverter : public ConditionXMLConverter{
203
204public:
205
208
218 const XMLObject& xmlObj,
219 RCP<ParameterEntry> parameterEntry) const = 0;
220
229 RCP<const ParameterCondition> condition, XMLObject& xmlObj) const = 0;
230
232
235
237 virtual RCP<Condition> convertXML(
238 const XMLObject& xmlObj,
239 const XMLParameterListReader::EntryIDsMap& entryIDsMap) const;
240
242 void convertCondition(
243 const RCP<const Condition> condition,
244 XMLObject& xmlObj,
245 const XMLParameterListWriter::EntryIDsMap& entryIDsMap) const;
246
248
249private:
250
253
255 static const std::string& getParameterEntryIdAttributeName(){
256 static const std::string parameterEntryIdAttributeName = "parameterId";
257 return parameterEntryIdAttributeName;
258 }
259
261
262};
263
276
277public:
278
281
284 const XMLObject& xmlObj,
285 RCP<ParameterEntry> parameterEntry) const;
286
289 RCP<const ParameterCondition> condition, XMLObject& xmlObj) const;
290
292
293private:
294
296 static const std::string& getValuesTagName(){
297 static const std::string valuesTagName = "Values";
298 return valuesTagName;
299 }
300
302 static const std::string& getStringTagName(){
303 static const std::string stringTagName = "String";
304 return stringTagName;
305 }
306
308 static const std::string& getStringValueAttributeName(){
309 static const std::string stringValueAttributeName = "value";
310 return stringValueAttributeName;
311 }
312
313
314};
315
324
325public:
326
329
332 const XMLObject& xmlObj,
333 RCP<ParameterEntry> parameterEntry) const;
334
337 RCP<const ParameterCondition> condition, XMLObject& xmlObj) const;
338
340
341};
342
352template<class T>
354
355public:
356
359
362 const XMLObject& xmlObj,
363 RCP<ParameterEntry> parameterEntry) const;
364
367 RCP<const ParameterCondition> condition, XMLObject& xmlObj) const;
368
370
371};
372
373template<class T>
376 const XMLObject& xmlObj,
377 RCP<ParameterEntry> parameterEntry) const
378{
379 int functionTag = xmlObj.findFirstChild(FunctionObject::getXMLTagName());
380 if(functionTag == -1){
381 return rcp(new NumberCondition<T>(parameterEntry));
382 }
383 else{
384 RCP<FunctionObject> functionObj =
386 RCP<SimpleFunctionObject<T> > castedFunction =
387 rcp_dynamic_cast<SimpleFunctionObject<T> >(functionObj);
388 return rcp(new NumberCondition<T>(parameterEntry, castedFunction));
389 }
390}
391
392template<class T>
394 RCP<const ParameterCondition> condition, XMLObject& xmlObj) const
395{
396 RCP<const NumberCondition<T> > castedCondition =
397 rcp_dynamic_cast<const NumberCondition<T> >(condition);
398 RCP<const SimpleFunctionObject<T> > functionObject =
399 castedCondition->getFunctionObject();
400 if(!functionObject.is_null()){
401 XMLObject functionXML =
403 xmlObj.addChild(functionXML);
404 }
405}
406
407
408
409} // namespace Teuchos
410
411
412#endif // TEUCHOS_STANDARDCONDITIONXMLCONVERTERS_HPP
413
Converts back and forth between XML and Dependencies.
A database for FunctionObjectXMLConverters.
Standard Conditions to be used.
RCP< BoolLogicCondition > getSpecificBoolLogicCondition(Condition::ConstConditionList &conditions) const
Replacement for std::vector that is compatible with the Teuchos Memory Management classes.
RCP< ParameterCondition > getSpecificParameterCondition(const XMLObject &xmlObj, RCP< ParameterEntry > parameterEntry) const
void addSpecificXMLTraits(RCP< const ParameterCondition > condition, XMLObject &xmlObj) const
virtual RCP< BoolLogicCondition > getSpecificBoolLogicCondition(Condition::ConstConditionList &conditions) const =0
Gets the specific BoolLogicCondition to be returned by this conveter when converting from XML.
virtual RCP< Condition > convertXML(const XMLObject &xmlObj, const XMLParameterListReader::EntryIDsMap &entryIDsMap) const
void convertCondition(const RCP< const Condition > condition, XMLObject &xmlObj, const XMLParameterListWriter::EntryIDsMap &entryIDsMap) const
An abstract base class for converting Dependencies to and from XML.
RCP< BoolLogicCondition > getSpecificBoolLogicCondition(Condition::ConstConditionList &conditions) const
static XMLObject convertFunctionObject(RCP< const FunctionObject > function)
Given a FunctionObject, converts the FunctionObject to XML.
static RCP< FunctionObject > convertXML(const XMLObject &xmlObject)
Given an XMLObject, converts the XMLObject to a FunctionObject.
static const std::string & getXMLTagName()
Returns the name of the XML tag used to indicate a funciton object.
void convertCondition(const RCP< const Condition > condition, XMLObject &xmlObj, const XMLParameterListWriter::EntryIDsMap &entryIDsMap) const
virtual RCP< Condition > convertXML(const XMLObject &xmlObj, const XMLParameterListReader::EntryIDsMap &entryIDsMap) const
An xml converter for NumberConditions The valid XML represntation for a NumberCondition is:
RCP< ParameterCondition > getSpecificParameterCondition(const XMLObject &xmlObj, RCP< ParameterEntry > parameterEntry) const
void addSpecificXMLTraits(RCP< const ParameterCondition > condition, XMLObject &xmlObj) const
A Number Condition is a Parameter Condition that evaluates whether or not a number parameter is great...
RCP< BoolLogicCondition > getSpecificBoolLogicCondition(Condition::ConstConditionList &conditions) const
virtual void addSpecificXMLTraits(RCP< const ParameterCondition > condition, XMLObject &xmlObj) const =0
Adds specific xml traits to the xmlObj for a particular ParmaterCondtion.
virtual RCP< ParameterCondition > getSpecificParameterCondition(const XMLObject &xmlObj, RCP< ParameterEntry > parameterEntry) const =0
Gets the specific ParameterCondition to be returned by this conveter when converting from XML.
Smart reference counting pointer class for automatic garbage collection.
An xml converter for StringConditions The valid XML represntation for a StringCondition is:
void addSpecificXMLTraits(RCP< const ParameterCondition > condition, XMLObject &xmlObj) const
RCP< ParameterCondition > getSpecificParameterCondition(const XMLObject &xmlObj, RCP< ParameterEntry > parameterEntry) const
Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object,...
void addChild(const XMLObject &child)
Add a child node to the node.
const XMLObject & getChild(int i) const
Return the i-th child node.
int findFirstChild(std::string tagName) const
Returns the index of the first child found with the given tag name. Returns -1 if no child is found.
std::map< ParameterEntry::ParameterEntryID, RCP< ParameterEntry > > EntryIDsMap
Convenience typedef.
std::map< RCP< const ParameterEntry >, ParameterEntry::ParameterEntryID, RCPConstComp > EntryIDsMap
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.