Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos_StandardConditionXMLConverters.cpp
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
14
15namespace Teuchos{
16
28
46
53
60
67
75
86
88 const XMLObject& xmlObj,
90{
93 getParameterEntryIdAttributeName());
95 entryIDsMap.find(paramID) == entryIDsMap.end(),
97 "Can't find a parameter entry with id " << paramID << " in the "
98 "given entryIDsMap!" << std::endl << std::endl);
100 xmlObj, entryIDsMap.find(paramID)->second);
101}
102
107{
110
112 entryIDsMap.find(castedCondition->getParameter()) == entryIDsMap.end(),
114 "Couldn't find an id for the parameter in the given entryIDsMap!" <<
115 std::endl << std::endl);
116
117 xmlObj.addAttribute(
118 getParameterEntryIdAttributeName(),
119 entryIDsMap.find(castedCondition->getParameter())->second);
120
122}
123
126 const XMLObject& xmlObj,
128{
130 int result = xmlObj.findFirstChild(getValuesTagName());
133 "A StringCondtion must have a tag with the name " <<
134 getValuesTagName() << " as one of it's children!");
135
136 XMLObject valuesTag = xmlObj.getChild(result);
137 for(int i=0; i< valuesTag.numChildren(); ++i){
138 XMLObject child = valuesTag.getChild(i);
139 if(child.getTag() == getStringTagName()){
140 values.append(child.getRequired(getStringValueAttributeName()));
141 }
142 }
143 return rcp(new StringCondition(parameterEntry, values));
144}
145
148{
151 XMLObject valueTag(getValuesTagName());
152 for(
154 castedCon->getValueList().begin();
155 it != castedCon->getValueList().end();
156 ++it)
157 {
158 XMLObject stringTag(getStringTagName());
159 stringTag.addAttribute(getStringValueAttributeName(), *it);
160 valueTag.addChild(stringTag);
161 }
162 xmlObj.addChild(valueTag);
163}
164
172
176
177
178} //namespace Teuchos
179
180
A database for ConditionXMLConverters.
A collection of standard ConditionXMLConverters.
A collection of Exceptions thrown when converting Conditions to and from XML.
A collection of Exceptions that can be potentially thrown when converting a ParameterList to and from...
RCP< BoolLogicCondition > getSpecificBoolLogicCondition(Condition::ConstConditionList &conditions) const
A Bool Logic Condition that returns the result or perfroming a logical AND on the conditions.
Replacement for std::vector that is compatible with the Teuchos Memory Management classes.
std::vector< T >::const_iterator const_iterator
The type of a const forward iterator.
Array< T > & append(const T &x)
Add a new entry at the end of the array.
RCP< ParameterCondition > getSpecificParameterCondition(const XMLObject &xmlObj, RCP< ParameterEntry > parameterEntry) const
void addSpecificXMLTraits(RCP< const ParameterCondition > condition, XMLObject &xmlObj) const
A Bool Condition is a Parameter Condition that evaluates whether or not a Boolean parameter is ture.
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
static RCP< Condition > convertXML(const XMLObject &xmlObject, const XMLParameterListReader::EntryIDsMap &entryIDsMap)
Given an XMLObject and IDtoConditionMap, converts the XMLObject to a Condition.
static XMLObject convertCondition(RCP< const Condition > condition, const XMLParameterListWriter::EntryIDsMap &entryIDsMap)
Given a condition and ConditiontoIDMap, converts the condition to XML.
RCP< BoolLogicCondition > getSpecificBoolLogicCondition(Condition::ConstConditionList &conditions) const
A Bool Logic Condition that returns the result or perfroming a logical EQUALS on the conditions.
Thrown when a referenced ParameterEntry can't be found.
Thrown when a StringConditon is missing it's Value tag.
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
A Not condition returns the result of performing a logical NOT on a given condition.
RCP< BoolLogicCondition > getSpecificBoolLogicCondition(Condition::ConstConditionList &conditions) const
A Bool Logic Condition that returns the result or perfroming a logical OR on the conditions.
void convertCondition(const RCP< const Condition > condition, XMLObject &xmlObj, const XMLParameterListWriter::EntryIDsMap &entryIDsMap) 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.
virtual RCP< Condition > convertXML(const XMLObject &xmlObj, const XMLParameterListReader::EntryIDsMap &entryIDsMap) const
Smart reference counting pointer class for automatic garbage collection.
void addSpecificXMLTraits(RCP< const ParameterCondition > condition, XMLObject &xmlObj) const
RCP< ParameterCondition > getSpecificParameterCondition(const XMLObject &xmlObj, RCP< ParameterEntry > parameterEntry) const
A String Condition is a Parameter Condition that evaluates whether or not a string parameter has take...
Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object,...
std::map< ParameterEntry::ParameterEntryID, RCP< ParameterEntry > > EntryIDsMap
Convenience typedef.
std::map< RCP< const ParameterEntry >, ParameterEntry::ParameterEntryID, RCPConstComp > EntryIDsMap
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
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.