10 #ifndef TEUCHOS_STANDARDDEPENDENCYXMLCONVERTERS_HPP
11 #define TEUCHOS_STANDARDDEPENDENCYXMLCONVERTERS_HPP
46 virtual void convertSpecialVisualAttributes(
83 void convertDependency(
97 static const std::string& getShowIfAttributeName(){
98 static const std::string showIfAttributeName =
"showIf";
99 return showIfAttributeName;
125 virtual void convertSpecialValidatorAttributes(
160 void convertDependency(
196 void convertSpecialVisualAttributes(
211 static const std::string stringValuesTagName =
"StringValues";
212 return stringValuesTagName;
223 static const std::string& getStringTagName(){
224 static const std::string stringTagName =
"String";
225 return stringTagName;
229 static const std::string& getValueAttributeName(){
230 static const std::string valueAttributeName =
"value";
231 return valueAttributeName;
259 void convertSpecialVisualAttributes(
327 castedDependency->getFunctionObject();
329 if(functionObject != null){
348 "A NumberVisualDependency can only have 1 dependee!" <<
349 std::endl << std::endl);
352 if(functionIndex != -1){
357 *(dependees.begin()), dependents, showIf, functionObject));
387 void convertSpecialVisualAttributes(
433 void convertSpecialValidatorAttributes(
447 static const std::string valuesAndValidatorsTag =
"ValuesAndValidators";
448 return valuesAndValidatorsTag;
458 static const std::string& getPairTag(){
459 static const std::string pairTag =
"Pair";
464 static const std::string& getValueAttributeName(){
465 static const std::string valueAttributeName =
"value";
466 return valueAttributeName;
470 static const std::string& getValidatorIdAttributeName(){
471 static const std::string validatorIDAttributeName =
"validatorId";
472 return validatorIDAttributeName;
476 static const std::string& getDefaultValidatorIdAttributeName(){
477 static const std::string defaultValidatorIdAttributeName =
478 "defaultValidatorId";
479 return defaultValidatorIdAttributeName;
510 void convertSpecialValidatorAttributes(
530 static const std::string& getFalseValidatorIdAttributeName(){
531 static const std::string falseValidatorIdAttributeName =
533 return falseValidatorIdAttributeName;
537 static const std::string& getTrueValidatorIdAttributeName(){
538 static const std::string trueValidatorIdAttributeName =
540 return trueValidatorIdAttributeName;
593 static const std::string rangesAndValidatorsTag =
"RangesAndValidators";
594 return rangesAndValidatorsTag;
605 static const std::string& getPairTag(){
606 static const std::string pairTag =
"Pair";
611 static const std::string& getMinAttributeName(){
612 static const std::string minAttributeName =
"min";
613 return minAttributeName;
617 static const std::string& getMaxAttributeName(){
618 static const std::string maxAttributeName =
"max";
619 return maxAttributeName;
624 static const std::string& getValidatorIdAttributeName(){
625 static const std::string validatorIdAttributeName =
"validatorId";
626 return validatorIdAttributeName;
630 static const std::string& getDefaultValidatorIdAttributeName(){
631 static const std::string defaultValidatorIdAttributeName =
632 "defaultValidatorId";
633 return defaultValidatorIdAttributeName;
650 XMLObject rangesAndValidatorsTag(getRangesAndValidatorsTag());
652 castedDependency->getRangeToValidatorMap();
655 it = castedDependency->getRangeToValidatorMap().begin();
656 it != castedDependency->getRangeToValidatorMap().end();
659 T min = it->first.first;
660 T max = it->first.second;
661 if(validatorIDsMap.
find(it->second) == validatorIDsMap.
end()){
662 validatorIDsMap.
insert(it->second);
665 validatorIDsMap.
find(it->second)->second;
669 pairTag.
addAttribute(getValidatorIdAttributeName(), validatorID);
670 rangesAndValidatorsTag.addChild(pairTag);
672 xmlObj.
addChild(rangesAndValidatorsTag);
674 castedDependency->getDefaultValidator();
676 if(validatorIDsMap.
find(defaultValidator) == validatorIDsMap.
end()){
677 validatorIDsMap.
insert(defaultValidator);
680 getDefaultValidatorIdAttributeName(),
681 validatorIDsMap.
find(defaultValidator)->second);
697 "Error: All RangeValidatorDependencies must have a " <<
698 getRangesAndValidatorsTag() <<
" tag!" << std::endl << std::endl);
704 for(
int i = 0 ; i < rangesAndValidatorsTag.
numChildren(); ++i){
706 T min = child.
getRequired<T>(getMinAttributeName());
707 T max = child.
getRequired<T>(getMaxAttributeName());
710 getValidatorIdAttributeName());
713 validatorIDsMap.
find(currentID) == validatorIDsMap.
end(),
715 "Could not find validator in given ValidatorIDsMap! " << std::endl <<
718 validatorIDsMap.
find(currentID)->second;
720 rangesAndValidators.insert(
726 if(xmlObj.
hasAttribute(getDefaultValidatorIdAttributeName())){
729 getDefaultValidatorIdAttributeName());
731 validatorIDsMap.
find(defaultValiID) == validatorIDsMap.
end(),
733 "Could not find a validator (for the default validator) " <<
734 "corresponding to the ID " << defaultValiID <<
735 " in the given validatorIDsMap!" << std::endl << std::endl);
736 defaultValidator = validatorIDsMap.
find(defaultValiID)->second;
740 dependee, dependents, rangesAndValidators, defaultValidator));
747 template<
class DependeeType,
class DependentType>
799 template<
class DependeeType,
class DependentType>
810 "A ArrayModifierDependency can only have 1 dependee!" <<
811 std::endl << std::endl);
814 if(functionIndex != -1){
819 getConcreteDependency(*(dependees.begin()), dependents, functionObject);
822 template<
class DependeeType,
class DependentType>
834 castedDep->getFunctionObject();
835 if(functionObject != null){
857 template<
class DependeeType,
class DependentType>
874 template<
class DependeeType,
class DependentType>
883 dependee, dependents,
function));
903 template<
class DependeeType,
class DependentType>
921 template<
class DependeeType,
class DependentType>
930 dependee, dependents,
function));
949 template<
class DependeeType,
class DependentType>
967 template<
class DependeeType,
class DependentType>
976 dependee, dependents,
function));
984 #endif // TEUCHOS_STANDARDDEPENDENCYXMLCONVERTERS_HPP
const_iterator find(int id) const
Retrieves and iterator to a validator and id based on the id given.
A dependency in which the number of rows in a parameter with a TwoDArray depends on the value of anot...
Maps Validators to integers.
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.
A dependency in which the number of rows in a parameter with a TwoDArray depends on the value of anot...
An xml converter for BoolVisualDepenencies.
std::set< RCP< ParameterEntry >, RCPComp > ParameterEntryList
A list of Dependees.
bool nonnull(const std::shared_ptr< T > &p)
Returns true if p.get()!=NULL.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
A class for converting TwoDRowDependencies to and from XML.
void addChild(const XMLObject &child)
Add a child node to the node.
void convertSpecialVisualAttributes(RCP< const VisualDependency > dependency, XMLObject &xmlObj, const XMLParameterListWriter::EntryIDsMap &entryIDsMap) const
void convertSpecialValidatorAttributes(RCP< const ValidatorDependency > dependency, XMLObject &xmlObj, ValidatortoIDMap &validatorIDsMap) const
static const std::string & getValuesAndValidatorsTag()
An xml converter for RangeValidatorDependencies.
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 RangeValidatorDependency says the following about the relationship between two parameters: Dependen...
A database for FunctionObjectXMLConverters.
An xml converter for BoolValidatorDependencies.
static const std::string & getStringValuesTagName()
Gets the StringValues Tag.
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...
An xml converter for StringVisualDepenencies.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
An xml converter for ValidatorDependencies.
An abstract base class for converting Dependencies to and from XML.
Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object...
A converter used to convert ArrayModifierDepdencies to and from xml.
A collection of Exceptions thrown when converting Dependencys to and from XML.
std::map< RCP< const ParameterEntry >, ParameterEntry::ParameterEntryID, RCPConstComp > EntryIDsMap
const_iterator end() const
Returns a const_reference to the end of the map.
Thrown when the rangesAndValidators tag for the RangeValidatorDepencyConverter can't be found...
A NumberArrayLengthDependency says the following about the relationship between two parameters: The l...
static const std::string & getXMLTagName()
Returns the name of the XML tag used to indicate a funciton object.
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 mapping validators to integers.
void insert(RCP< const ParameterEntryValidator > toInsert)
inserts an IDValidatorPair into the map.
void addAttribute(const std::string &name, T value)
Lookup whether or not Doubles are allowed.
A class for converting TwoDColDependencies to and from XML.
const_iterator end() const
Returns a const_reference to the end of the map.
A collection of standard dependencies.
void convertDependency(const RCP< const Dependency > dependency, XMLObject &xmlObj, const XMLParameterListWriter::EntryIDsMap &entryIDsMap, ValidatortoIDMap &validatorIDsMap) const
Converts back and forth between XML and Dependencies.
An xml converter for StringValidatorDependencies.
An xml converter for ConditionVisualDependencies.
const_iterator find(const RCP< const ParameterEntryValidator > validator) const
Returns an iterator to the validator and id specified by the validator.
RCP< Dependency > convertXML(const XMLObject &xmlObj, const Dependency::ConstParameterEntryList dependees, const Dependency::ParameterEntryList dependets, const XMLParameterListReader::EntryIDsMap &entryIDsMap, const IDtoValidatorMap &validatorIDsMap) const
std::map< ParameterEntry::ParameterEntryID, RCP< ParameterEntry > > EntryIDsMap
Convenience typedef.
Thrown when a Dependency has too many dependees specified in its XML.
int numChildren() const
Return the number of child nodes owned by this node.
An abstract base class for all dependencies which modify the dimensional attributes of an Array param...
static const std::string & getRangesAndValidatorsTag()
An xml converter for NumberVisualDependencies.
Smart reference counting pointer class for automatic garbage collection.
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...
static RCP< FunctionObject > convertXML(const XMLObject &xmlObject)
Given an XMLObject, converts the XMLObject to a FunctionObject.
std::pair< Range, RCP< const ParameterEntryValidator > > RangeValidatorPair
Convenience typedef.
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.
Thrown when converting a dependency that has validaotrs to and from XML. This excetpion indicates tha...
std::pair< T, T > Range
Convenience typedef.
An xml converter for NumberArrayLengthDependencies.
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...
A number visual dependency says the following about the relationship between two elements in a Parame...
const std::string & getRequired(const std::string &name) const
Get an attribute, throwing an std::exception if it is not found.
std::map< Range, RCP< const ParameterEntryValidator > > RangeToValidatorMap
Convenience typedef.
An xml converter for VisualDepenencies.