Teuchos Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
Teuchos_StandardConditionXMLConverters.cpp
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
46
47namespace Teuchos{
48
60
78
85
92
99
107
118
120 const XMLObject& xmlObj,
122{
127 entryIDsMap.find(paramID) == entryIDsMap.end(),
129 "Can't find a parameter entry with id " << paramID << " in the "
130 "given entryIDsMap!" << std::endl << std::endl);
132 xmlObj, entryIDsMap.find(paramID)->second);
133}
134
139{
142
144 entryIDsMap.find(castedCondition->getParameter()) == entryIDsMap.end(),
146 "Couldn't find an id for the parameter in the given entryIDsMap!" <<
147 std::endl << std::endl);
148
149 xmlObj.addAttribute(
151 entryIDsMap.find(castedCondition->getParameter())->second);
152
154}
155
158 const XMLObject& xmlObj,
160{
162 int result = xmlObj.findFirstChild(getValuesTagName());
165 "A StringCondtion must have a tag with the name " <<
166 getValuesTagName() << " as one of it's children!");
167
168 XMLObject valuesTag = xmlObj.getChild(result);
169 for(int i=0; i< valuesTag.numChildren(); ++i){
170 XMLObject child = valuesTag.getChild(i);
171 if(child.getTag() == getStringTagName()){
172 values.append(child.getRequired(getStringValueAttributeName()));
173 }
174 }
175 return rcp(new StringCondition(parameterEntry, values));
176}
177
196
204
208
209
210} //namespace Teuchos
211
212
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.
static const std::string & getParameterEntryIdAttributeName()
gets the ParameterEntryID attribute name.
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
Concrete serial communicator subclass.
int getTag() const
The current tag.
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.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.