Teuchos Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
Teuchos_DependencyXMLConverter.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
44
45
46namespace Teuchos{
47
48
49RCP<Dependency>
51 const XMLObject& xmlObj,
54{
57
60 "Could not find any dependees for a dependency!"
61 <<std::endl <<std::endl);
62
65 "Could not find any dependents for a dependency!"
66 <<std::endl <<std::endl);
67
68 for(int i=0; i<xmlObj.numChildren(); ++i){
69 XMLObject child = xmlObj.getChild(i);
74
77 "Can't find a Dependee ParameterEntry associated with the ID: " <<
78 dependeeID << std::endl << std::endl);
79 dependees.insert(entryIDsMap.find(dependeeID)->second);
80 }
81 else if(child.getTag() == getDependentTagName()){
85
88 "Can't find a Dependent ParameterEntry associated with the ID: " <<
89 dependentID << std::endl << std::endl);
90 dependents.insert(entryIDsMap.find(dependentID)->second);
91 }
92 }
93
94 return convertXML(
96}
97
103{
105
106 toReturn.addAttribute(getTypeAttributeName(),
107 dependency->getTypeAttributeValue());
108
109 Dependency::ConstParameterEntryList::const_iterator it =
110 dependency->getDependees().begin();
111
112 for(;it != dependency->getDependees().end(); ++it){
116 "Can't find the Dependee of a dependency in the given " <<
117 "EntryIDsMap. Occurred when converting " <<
118 "to XML" << std::endl << std::endl);
120 getParameterIdAttributeName(), entryIDsMap.find(*it)->second);
121 toReturn.addChild(currentDependee);
122 }
123
124 it = dependency->getDependents().begin();
125 for(; it != dependency->getDependents().end(); ++it){
129 "Can't find the Dependent of a dependency in the given " <<
130 "ValidatordIDsMap. Occurred when converting " <<
131 "to XML" << std::endl << std::endl);
133 getParameterIdAttributeName(), entryIDsMap.find(*it)->second);
134 toReturn.addChild(currentDependent);
135 }
136
138
139 return toReturn;
140}
141
142
143} // namespace Teuchos
144
Converts back and forth between XML and Dependencies.
A collection of Exceptions thrown when converting Dependencys to and from XML.
static const std::string & getDependentTagName()
Returns the string to be used for the dependent tag.
virtual void convertDependency(const RCP< const Dependency > dependency, XMLObject &xmlObj, const XMLParameterListWriter::EntryIDsMap &entryIDsMap, ValidatortoIDMap &validatorIDsMap) const =0
Preforms any and all special dependency conversion that is specific to a particlar Dependency.
static const std::string & getTypeAttributeName()
Returns the string to be used for the type attribute.
static const std::string & getParameterIdAttributeName()
Returns the string to be used for the ParameterID attribute.
virtual RCP< Dependency > convertXML(const XMLObject &xmlObj, const Dependency::ConstParameterEntryList dependees, const Dependency::ParameterEntryList dependets, const XMLParameterListReader::EntryIDsMap &entryIDsMap, const IDtoValidatorMap &validatorIDsMap) const =0
Preforms any and all special xml conversion that is specific to a particular Dependency.
RCP< Dependency > fromXMLtoDependency(const XMLObject &xmlObj, const XMLParameterListReader::EntryIDsMap &entryIDsMap, const IDtoValidatorMap &validatorIDsMap) const
Converts a given XMLObject to a Dependency.
static const std::string & getDependeeTagName()
Returns the string to be used for the dependee tag.
XMLObject fromDependencytoXML(const RCP< const Dependency > dependency, const XMLParameterListWriter::EntryIDsMap &entryIDsMap, ValidatortoIDMap &validatorIDsMap) const
Converters a given ParameterEntryValidator to XML.
static const std::string & getXMLTagName()
Returns the XML tag to use when serializing Dependencies.
std::set< RCP< ParameterEntry >, RCPComp > ParameterEntryList
A list of Dependees.
std::set< RCP< const ParameterEntry >, RCPConstComp > ConstParameterEntryList
A list of dependents.
Maps Validators to integers.
Thrown when no dependes of a dependency can't be found when converting the dependency to or from XML.
Thrown when no dependess of a dependency are specified when converting the dependency from XML.
Thrown when a dependent of a dependency cant be found when converting the dependency to or from XML.
Thrown when no dependents of a dependency are specified when converting the dependency from XML.
Concrete serial communicator subclass.
int getTag() const
The current tag.
A class for mapping validators to integers.
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.