Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
54 namespace Teuchos {
55 
56 
60 
61 public:
62 
65 
74  Condition::ConstConditionList& conditions) const = 0;
75 
77 
80 
82  virtual RCP<Condition> convertXML(
83  const XMLObject& xmlObj,
84  const XMLParameterListReader::EntryIDsMap& entryIDsMap) const;
85 
87  void convertCondition(
88  const RCP<const Condition> condition,
89  XMLObject& xmlObj,
90  const XMLParameterListWriter::EntryIDsMap& entryIDsMap) const;
91 
93 
94 };
95 
106 
107 public:
108 
111 
114  Condition::ConstConditionList& conditions) const;
115 
117 
118 };
119 
130 
131 public:
132 
135 
138  Condition::ConstConditionList& conditions) const;
139 
141 
142 };
143 
144 
155 
156 public:
157 
160 
163  Condition::ConstConditionList& conditions) const;
164 
166 
167 };
168 
179 
180 public:
181 
184 
186  virtual RCP<Condition> convertXML(
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 
203 
204 public:
205 
208 
217  virtual RCP<ParameterCondition> getSpecificParameterCondition(
218  const XMLObject& xmlObj,
219  RCP<ParameterEntry> parameterEntry) const = 0;
220 
228  virtual void addSpecificXMLTraits(
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 
249 private:
250 
253 
255  static const std::string& getParameterEntryIdAttributeName(){
256  static const std::string parameterEntryIdAttributeName = "parameterId";
257  return parameterEntryIdAttributeName;
258  }
259 
261 
262 };
263 
276 
277 public:
278 
281 
284  const XMLObject& xmlObj,
285  RCP<ParameterEntry> parameterEntry) const;
286 
289  RCP<const ParameterCondition> condition, XMLObject& xmlObj) const;
290 
292 
293 private:
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 
325 public:
326 
329 
332  const XMLObject& xmlObj,
333  RCP<ParameterEntry> parameterEntry) const;
334 
337  RCP<const ParameterCondition> condition, XMLObject& xmlObj) const;
338 
340 
341 };
342 
352 template<class T>
354 
355 public:
356 
359 
362  const XMLObject& xmlObj,
363  RCP<ParameterEntry> parameterEntry) const;
364 
367  RCP<const ParameterCondition> condition, XMLObject& xmlObj) const;
368 
370 
371 };
372 
373 template<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 
392 template<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 
void convertCondition(const RCP< const Condition > condition, XMLObject &xmlObj, const XMLParameterListWriter::EntryIDsMap &entryIDsMap) const
RCP< ParameterCondition > getSpecificParameterCondition(const XMLObject &xmlObj, RCP< ParameterEntry > parameterEntry) const
An xml converter for StringConditions The valid XML represntation for a StringCondition is: ...
virtual RCP< Condition > convertXML(const XMLObject &xmlObj, const XMLParameterListReader::EntryIDsMap &entryIDsMap) const
RCP< ParameterCondition > getSpecificParameterCondition(const XMLObject &xmlObj, RCP< ParameterEntry > parameterEntry) const
static XMLObject convertFunctionObject(RCP< const FunctionObject > function)
Given a FunctionObject, converts the FunctionObject to XML.
void addChild(const XMLObject &child)
Add a child node to the node.
RCP< BoolLogicCondition > getSpecificBoolLogicCondition(Condition::ConstConditionList &conditions) const
A Number Condition is a Parameter Condition that evaluates whether or not a number parameter is great...
A database for FunctionObjectXMLConverters.
Converts back and forth between XML and Dependencies.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
static const std::string & getParameterEntryIdAttributeName()
gets the ParameterEntryID attribute name.
Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object...
std::map< RCP< const ParameterEntry >, ParameterEntry::ParameterEntryID, RCPConstComp > EntryIDsMap
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
An xml converter for NumberConditions The valid XML represntation for a NumberCondition is: ...
#define TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT
virtual RCP< BoolLogicCondition > getSpecificBoolLogicCondition(Condition::ConstConditionList &conditions) const =0
Gets the specific BoolLogicCondition to be returned by this conveter when converting from XML...
RCP< BoolLogicCondition > getSpecificBoolLogicCondition(Condition::ConstConditionList &conditions) const
std::map< ParameterEntry::ParameterEntryID, RCP< ParameterEntry > > EntryIDsMap
Convenience typedef.
An abstract base class for converting Dependencies to and from XML.
RCP< BoolLogicCondition > getSpecificBoolLogicCondition(Condition::ConstConditionList &conditions) const
void addSpecificXMLTraits(RCP< const ParameterCondition > condition, XMLObject &xmlObj) const
An xml converter for BoolLogicConditions.
Smart reference counting pointer class for automatic garbage collection.
void addSpecificXMLTraits(RCP< const ParameterCondition > condition, XMLObject &xmlObj) const
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...
static RCP< FunctionObject > convertXML(const XMLObject &xmlObject)
Given an XMLObject, converts the XMLObject to a FunctionObject.
RCP< ParameterCondition > getSpecificParameterCondition(const XMLObject &xmlObj, RCP< ParameterEntry > parameterEntry) const
const XMLObject & getChild(int i) const
Return the i-th child node.
void addSpecificXMLTraits(RCP< const ParameterCondition > condition, XMLObject &xmlObj) const
Standard Conditions to be used.
virtual RCP< Condition > convertXML(const XMLObject &xmlObj, const XMLParameterListReader::EntryIDsMap &entryIDsMap) const
Replacement for std::vector that is compatible with the Teuchos Memory Management classes...