Teuchos Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
Teuchos_StandardDependencyXMLConverters.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_STANDARDDEPENDENCYXMLCONVERTERS_HPP
43#define TEUCHOS_STANDARDDEPENDENCYXMLCONVERTERS_HPP
44
54
55
56namespace Teuchos {
57
58
137
201
221
222public:
223
226
228 void convertSpecialVisualAttributes(
232
234 RCP<VisualDependency> convertSpecialVisualAttributes(
235 const XMLObject& xmlObj,
238 bool showIf,
240
242 static const std::string& getStringValuesTagName(){
243 static const std::string stringValuesTagName = "StringValues";
244 return stringValuesTagName;
245 }
246
248
249private:
250
253
255 static const std::string& getStringTagName(){
256 static const std::string stringTagName = "String";
257 return stringTagName;
258 }
259
261 static const std::string& getValueAttributeName(){
262 static const std::string valueAttributeName = "value";
263 return valueAttributeName;
264 }
265
267
268};
269
284
285public:
286
289
291 void convertSpecialVisualAttributes(
295
297 RCP<VisualDependency> convertSpecialVisualAttributes(
298 const XMLObject& xmlObj,
301 bool showIf,
303
305
306};
307
324template<class T>
349
350template<class T>
368
369template<class T>
392
411{
412
413public:
414
417
419 void convertSpecialVisualAttributes(
423
425 RCP<VisualDependency> convertSpecialVisualAttributes(
426 const XMLObject& xmlObj,
429 bool showIf,
431
433
434};
435
436
458
459public:
460
463
465 void convertSpecialValidatorAttributes(
469
471 RCP<ValidatorDependency> convertSpecialValidatorAttributes(
472 const XMLObject& xmlObj,
475 const IDtoValidatorMap& validatorIDsMap) const;
476
478 static const std::string& getValuesAndValidatorsTag(){
479 static const std::string valuesAndValidatorsTag = "ValuesAndValidators";
481 }
482
484
485private:
488
490 static const std::string& getPairTag(){
491 static const std::string pairTag = "Pair";
492 return pairTag;
493 }
494
496 static const std::string& getValueAttributeName(){
497 static const std::string valueAttributeName = "value";
498 return valueAttributeName;
499 }
500
502 static const std::string& getValidatorIdAttributeName(){
503 static const std::string validatorIDAttributeName = "validatorId";
505 }
506
508 static const std::string& getDefaultValidatorIdAttributeName(){
509 static const std::string defaultValidatorIdAttributeName =
510 "defaultValidatorId";
512 }
513
515
516};
517
535
536public:
537
540
542 void convertSpecialValidatorAttributes(
546
548 RCP<ValidatorDependency> convertSpecialValidatorAttributes(
549 const XMLObject& xmlObj,
552 const IDtoValidatorMap& validatorIDsMap) const;
553
555
556private:
557
560
562 static const std::string& getFalseValidatorIdAttributeName(){
563 static const std::string falseValidatorIdAttributeName =
564 "falseValidatorId";
566 }
567
569 static const std::string& getTrueValidatorIdAttributeName(){
570 static const std::string trueValidatorIdAttributeName =
571 "trueValidatorId";
573 }
574
576
577};
578
601template<class T>
604
605public:
606
609
615
618 const XMLObject& xmlObj,
621 const IDtoValidatorMap& validatorIDsMap) const;
622
624 static const std::string& getRangesAndValidatorsTag(){
625 static const std::string rangesAndValidatorsTag = "RangesAndValidators";
627 }
628
630
631private:
634
635
637 static const std::string& getPairTag(){
638 static const std::string pairTag = "Pair";
639 return pairTag;
640 }
641
643 static const std::string& getMinAttributeName(){
644 static const std::string minAttributeName = "min";
645 return minAttributeName;
646 }
647
649 static const std::string& getMaxAttributeName(){
650 static const std::string maxAttributeName = "max";
651 return maxAttributeName;
652 }
653
654
656 static const std::string& getValidatorIdAttributeName(){
657 static const std::string validatorIdAttributeName = "validatorId";
659 }
660
662 static const std::string& getDefaultValidatorIdAttributeName(){
663 static const std::string defaultValidatorIdAttributeName =
664 "defaultValidatorId";
666 }
667
669
670};
671
672template<class T>
673void
678{
681
682 XMLObject rangesAndValidatorsTag(getRangesAndValidatorsTag());
683
684 castedDependency->getRangeToValidatorMap();
685 for(
687 it = castedDependency->getRangeToValidatorMap().begin();
688 it != castedDependency->getRangeToValidatorMap().end();
689 ++it)
690 {
691 T min = it->first.first;
692 T max = it->first.second;
693 if(validatorIDsMap.find(it->second) == validatorIDsMap.end()){
694 validatorIDsMap.insert(it->second);
695 }
697 validatorIDsMap.find(it->second)->second;
698 XMLObject pairTag(getPairTag());
699 pairTag.addAttribute(getMinAttributeName(), min);
700 pairTag.addAttribute(getMaxAttributeName(), max);
701 pairTag.addAttribute(getValidatorIdAttributeName(), validatorID);
703 }
706 castedDependency->getDefaultValidator();
710 }
711 xmlObj.addAttribute(
712 getDefaultValidatorIdAttributeName(),
713 validatorIDsMap.find(defaultValidator)->second);
714 }
715}
716
717template<class T>
720 const XMLObject& xmlObj,
724{
725
726 int result = xmlObj.findFirstChild(getRangesAndValidatorsTag());
729 "Error: All RangeValidatorDependencies must have a " <<
730 getRangesAndValidatorsTag() << " tag!" << std::endl << std::endl);
731
733
736 for(int i = 0 ; i < rangesAndValidatorsTag.numChildren(); ++i){
738 T min = child.getRequired<T>(getMinAttributeName());
739 T max = child.getRequired<T>(getMaxAttributeName());
742 getValidatorIdAttributeName());
743
747 "Could not find validator in given ValidatorIDsMap! " << std::endl <<
748 std::endl);
750 validatorIDsMap.find(currentID)->second;
751
752 rangesAndValidators.insert(
754 typename RangeValidatorDependency<T>::Range(min, max), validator));
755 }
756
758 if(xmlObj.hasAttribute(getDefaultValidatorIdAttributeName())){
761 getDefaultValidatorIdAttributeName());
765 "Could not find a validator (for the default validator) " <<
766 "corresponding to the ID " << defaultValiID <<
767 " in the given validatorIDsMap!" << std::endl << std::endl);
769 }
770
773}
774
779template<class DependeeType, class DependentType>
830
831template<class DependeeType, class DependentType>
834 const XMLObject& xmlObj,
837 const XMLParameterListReader::EntryIDsMap& /* entryIDsMap */,
838 const IDtoValidatorMap& /* validatorIDsMap */) const
839{
842 "A ArrayModifierDependency can only have 1 dependee!" <<
843 std::endl << std::endl);
845 int functionIndex = xmlObj.findFirstChild(FunctionObject::getXMLTagName());
846 if(functionIndex != -1){
849 }
850 return
851 getConcreteDependency(*(dependees.begin()), dependents, functionObject);
852}
853
854template<class DependeeType, class DependentType>
855void
873
874
889template<class DependeeType, class DependentType>
905
906template<class DependeeType, class DependentType>
917
918
935template<class DependeeType, class DependentType>
952
953template<class DependeeType, class DependentType>
964
981template<class DependeeType, class DependentType>
998
999template<class DependeeType, class DependentType>
1010
1011
1012
1013} // namespace Teuchos
1014
1015
1016#endif // TEUCHOS_STANDARDDEPENDENCYXMLCONVERTERS_HPP
#define TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT
Converts back and forth between XML and Dependencies.
A database for FunctionObjectXMLConverters.
A collection of standard dependencies.
A collection of Exceptions thrown when converting Dependencys to and from XML.
A converter used to convert ArrayModifierDepdencies to and from xml.
void convertDependency(const RCP< const Dependency > dependency, XMLObject &xmlObj, const XMLParameterListWriter::EntryIDsMap &entryIDsMap, ValidatortoIDMap &validatorIDsMap) const
RCP< Dependency > convertXML(const XMLObject &xmlObj, const Dependency::ConstParameterEntryList dependees, const Dependency::ParameterEntryList dependets, const XMLParameterListReader::EntryIDsMap &entryIDsMap, const IDtoValidatorMap &validatorIDsMap) const
virtual RCP< ArrayModifierDependency< DependeeType, DependentType > > getConcreteDependency(RCP< const ParameterEntry > dependee, Dependency::ParameterEntryList dependents, RCP< const SimpleFunctionObject< DependeeType > > function) const =0
Obtains a concrete ArrayModifierDependency given a dependee, dependtns, and a funciton object.
int size(const Comm< Ordinal > &comm)
Get the number of processes in the communicator.
An abstract base class for converting Dependencies to and from XML.
std::set< RCP< ParameterEntry >, RCPComp > ParameterEntryList
A list of Dependees.
std::set< RCP< const ParameterEntry >, RCPConstComp > ConstParameterEntryList
A list of dependents.
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.
Maps Validators to integers.
Thrown when the rangesAndValidators tag for the RangeValidatorDepencyConverter can't be found.
Thrown when converting a dependency that has validaotrs to and from XML. This excetpion indicates tha...
virtual RCP< ArrayModifierDependency< DependeeType, DependentType > > getConcreteDependency(RCP< const ParameterEntry > dependee, Dependency::ParameterEntryList dependents, RCP< const SimpleFunctionObject< DependeeType > > function) const
Obtains a concrete ArrayModifierDependency given a dependee, dependtns, and a funciton object.
void convertSpecialVisualAttributes(RCP< const VisualDependency > dependency, XMLObject &xmlObj, const XMLParameterListWriter::EntryIDsMap &entryIDsMap) const
Smart reference counting pointer class for automatic garbage collection.
void convertSpecialValidatorAttributes(RCP< const ValidatorDependency > dependency, XMLObject &xmlObj, ValidatortoIDMap &validatorIDsMap) const
A RangeValidatorDependency says the following about the relationship between two parameters: Dependen...
std::pair< Range, RCP< const ParameterEntryValidator > > RangeValidatorPair
Convenience typedef.
std::map< Range, RCP< const ParameterEntryValidator > > RangeToValidatorMap
Convenience typedef.
std::pair< T, T > Range
Convenience typedef.
Concrete serial communicator subclass.
static const std::string & getValueAttributeName()
Gets the Value attribute name.
static const std::string & getStringValuesTagName()
Gets the StringValues Tag.
static const std::string & getStringTagName()
Gets the String Tag.
Thrown when a Dependency has too many dependees specified in its XML.
A class for converting TwoDColDependencies to and from XML.
virtual RCP< ArrayModifierDependency< DependeeType, DependentType > > getConcreteDependency(RCP< const ParameterEntry > dependee, Dependency::ParameterEntryList dependents, RCP< const SimpleFunctionObject< DependeeType > > function) const
Obtains a concrete ArrayModifierDependency given a dependee, dependtns, and a funciton object.
A class for converting TwoDRowDependencies to and from XML.
virtual RCP< ArrayModifierDependency< DependeeType, DependentType > > getConcreteDependency(RCP< const ParameterEntry > dependee, Dependency::ParameterEntryList dependents, RCP< const SimpleFunctionObject< DependeeType > > function) const
Obtains a concrete ArrayModifierDependency given a dependee, dependtns, and a funciton object.
virtual RCP< ValidatorDependency > convertSpecialValidatorAttributes(const XMLObject &xmlObj, RCP< const ParameterEntry > dependee, const Dependency::ParameterEntryList dependents, const IDtoValidatorMap &validatorIDsMap) const =0
Converts any special aspects of a specific validator dependency from xml.
virtual void convertSpecialValidatorAttributes(RCP< const ValidatorDependency > dependency, XMLObject &xmlObj, ValidatortoIDMap &validatorIDsMap) const =0
Converts any special aspects of a specific validator dependency to xml.
A class for mapping validators to integers.
virtual void convertSpecialVisualAttributes(RCP< const VisualDependency > dependency, XMLObject &xmlObj, const XMLParameterListWriter::EntryIDsMap &entryIDsMap) const =0
Converts any special aspects of a specific visual dependency to xml.
static const std::string & getShowIfAttributeName()
Gets the name of the showif attribute.
virtual RCP< VisualDependency > convertSpecialVisualAttributes(const XMLObject &xmlObj, const Dependency::ConstParameterEntryList dependees, const Dependency::ParameterEntryList dependets, bool showIf, const XMLParameterListReader::EntryIDsMap &entryIDsMap) const =0
Converts any special aspects of a specific visual dependency from xml.
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.
bool nonnull(const std::shared_ptr< T > &p)
Returns true if p.get()!=NULL.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.