42#ifndef TEUCHOS_STANDARDDEPENDENCYXMLCONVERTERS_HPP
43#define TEUCHOS_STANDARDDEPENDENCYXMLCONVERTERS_HPP
115 void convertDependency(
129 static const std::string& getShowIfAttributeName(){
130 static const std::string showIfAttributeName =
"showIf";
131 return showIfAttributeName;
192 void convertDependency(
228 void convertSpecialVisualAttributes(
243 static const std::string stringValuesTagName =
"StringValues";
244 return stringValuesTagName;
255 static const std::string& getStringTagName(){
256 static const std::string stringTagName =
"String";
257 return stringTagName;
261 static const std::string& getValueAttributeName(){
262 static const std::string valueAttributeName =
"value";
263 return valueAttributeName;
291 void convertSpecialVisualAttributes(
357 rcp_dynamic_cast<const NumberVisualDependency<T> >(dependency);
359 castedDependency->getFunctionObject();
361 if(functionObject != null){
380 "A NumberVisualDependency can only have 1 dependee!" <<
381 std::endl << std::endl);
384 if(functionIndex != -1){
385 functionObject = rcp_dynamic_cast<SimpleFunctionObject<T> >(
389 *(dependees.begin()), dependents, showIf, functionObject));
419 void convertSpecialVisualAttributes(
465 void convertSpecialValidatorAttributes(
479 static const std::string valuesAndValidatorsTag =
"ValuesAndValidators";
480 return valuesAndValidatorsTag;
490 static const std::string& getPairTag(){
491 static const std::string pairTag =
"Pair";
496 static const std::string& getValueAttributeName(){
497 static const std::string valueAttributeName =
"value";
498 return valueAttributeName;
502 static const std::string& getValidatorIdAttributeName(){
503 static const std::string validatorIDAttributeName =
"validatorId";
504 return validatorIDAttributeName;
508 static const std::string& getDefaultValidatorIdAttributeName(){
509 static const std::string defaultValidatorIdAttributeName =
510 "defaultValidatorId";
511 return defaultValidatorIdAttributeName;
542 void convertSpecialValidatorAttributes(
562 static const std::string& getFalseValidatorIdAttributeName(){
563 static const std::string falseValidatorIdAttributeName =
565 return falseValidatorIdAttributeName;
569 static const std::string& getTrueValidatorIdAttributeName(){
570 static const std::string trueValidatorIdAttributeName =
572 return trueValidatorIdAttributeName;
625 static const std::string rangesAndValidatorsTag =
"RangesAndValidators";
626 return rangesAndValidatorsTag;
637 static const std::string& getPairTag(){
638 static const std::string pairTag =
"Pair";
643 static const std::string& getMinAttributeName(){
644 static const std::string minAttributeName =
"min";
645 return minAttributeName;
649 static const std::string& getMaxAttributeName(){
650 static const std::string maxAttributeName =
"max";
651 return maxAttributeName;
656 static const std::string& getValidatorIdAttributeName(){
657 static const std::string validatorIdAttributeName =
"validatorId";
658 return validatorIdAttributeName;
662 static const std::string& getDefaultValidatorIdAttributeName(){
663 static const std::string defaultValidatorIdAttributeName =
664 "defaultValidatorId";
665 return defaultValidatorIdAttributeName;
680 rcp_dynamic_cast<const RangeValidatorDependency<T> >(dependency,
true);
682 XMLObject rangesAndValidatorsTag(getRangesAndValidatorsTag());
684 castedDependency->getRangeToValidatorMap();
687 it = castedDependency->getRangeToValidatorMap().begin();
688 it != castedDependency->getRangeToValidatorMap().end();
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);
697 validatorIDsMap.
find(it->second)->second;
701 pairTag.
addAttribute(getValidatorIdAttributeName(), validatorID);
702 rangesAndValidatorsTag.addChild(pairTag);
704 xmlObj.
addChild(rangesAndValidatorsTag);
706 castedDependency->getDefaultValidator();
708 if(validatorIDsMap.
find(defaultValidator) == validatorIDsMap.
end()){
709 validatorIDsMap.
insert(defaultValidator);
712 getDefaultValidatorIdAttributeName(),
713 validatorIDsMap.
find(defaultValidator)->second);
729 "Error: All RangeValidatorDependencies must have a " <<
730 getRangesAndValidatorsTag() <<
" tag!" << std::endl << std::endl);
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());
745 validatorIDsMap.
find(currentID) == validatorIDsMap.
end(),
747 "Could not find validator in given ValidatorIDsMap! " << std::endl <<
750 validatorIDsMap.
find(currentID)->second;
752 rangesAndValidators.insert(
758 if(xmlObj.
hasAttribute(getDefaultValidatorIdAttributeName())){
761 getDefaultValidatorIdAttributeName());
763 validatorIDsMap.
find(defaultValiID) == validatorIDsMap.
end(),
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);
768 defaultValidator = validatorIDsMap.
find(defaultValiID)->second;
772 dependee, dependents, rangesAndValidators, defaultValidator));
779template<
class DependeeType,
class DependentType>
831template<
class DependeeType,
class DependentType>
842 "A ArrayModifierDependency can only have 1 dependee!" <<
843 std::endl << std::endl);
846 if(functionIndex != -1){
847 functionObject = rcp_dynamic_cast<SimpleFunctionObject<DependeeType> >(
851 getConcreteDependency(*(dependees.begin()), dependents, functionObject);
854template<
class DependeeType,
class DependentType>
863 rcp_dynamic_cast<const ArrayModifierDependency<DependeeType, DependentType> >(
866 castedDep->getFunctionObject();
867 if(functionObject != null){
889template<
class DependeeType,
class DependentType>
906template<
class DependeeType,
class DependentType>
915 dependee, dependents, function));
935template<
class DependeeType,
class DependentType>
953template<
class DependeeType,
class DependentType>
962 dependee, dependents, function));
981template<
class DependeeType,
class DependentType>
999template<
class DependeeType,
class DependentType>
1008 dependee, dependents, function));
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.
An xml converter for BoolValidatorDependencies.
An xml converter for BoolVisualDepenencies.
An xml converter for ConditionVisualDependencies.
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.
const_iterator end() const
Returns a const_reference to the end of the map.
const_iterator find(int id) const
Retrieves and iterator to a validator and id based on the id given.
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...
An xml converter for NumberArrayLengthDependencies.
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 NumberArrayLengthDependency says the following about the relationship between two parameters: The l...
An xml converter for NumberVisualDependencies.
void convertSpecialVisualAttributes(RCP< const VisualDependency > dependency, XMLObject &xmlObj, const XMLParameterListWriter::EntryIDsMap &entryIDsMap) const
A number visual dependency says the following about the relationship between two elements in a Parame...
Smart reference counting pointer class for automatic garbage collection.
An xml converter for RangeValidatorDependencies.
void convertSpecialValidatorAttributes(RCP< const ValidatorDependency > dependency, XMLObject &xmlObj, ValidatortoIDMap &validatorIDsMap) const
static const std::string & getRangesAndValidatorsTag()
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.
A simple function object that applies a given operand to a spcified arguement using a specific operat...
An xml converter for StringValidatorDependencies.
static const std::string & getValuesAndValidatorsTag()
An xml converter for StringVisualDepenencies.
static const std::string & getStringValuesTagName()
Gets the StringValues 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 dependency in which the number of rows in a parameter with a TwoDArray depends on the value of anot...
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.
A dependency in which the number of rows in a parameter with a TwoDArray depends on the value of anot...
An xml converter for ValidatorDependencies.
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.
const_iterator end() const
Returns a const_reference to the end of the map.
void insert(RCP< const ParameterEntryValidator > toInsert)
inserts an IDValidatorPair into the map.
const_iterator find(const RCP< const ParameterEntryValidator > validator) const
Returns an iterator to the validator and id specified by the validator.
An xml converter for VisualDepenencies.
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.
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,...
void addChild(const XMLObject &child)
Add a child node to the node.
const std::string & getRequired(const std::string &name) const
Get an attribute, throwing an std::exception if it is not found.
void addAttribute(const std::string &name, T value)
Lookup whether or not Doubles are allowed.
const XMLObject & getChild(int i) const
Return the i-th child node.
bool hasAttribute(const std::string &name) const
Find out if the current node has an attribute of the specified name.
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.
int numChildren() const
Return the number of child nodes owned by this node.
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.
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.