44 #ifndef TEUCHOS_STANDARDDEPENDCIES_HPP_
45 #define TEUCHOS_STANDARDDEPENDCIES_HPP_
51 #include "Teuchos_Dependency.hpp"
52 #include "Teuchos_StandardParameterEntryValidators.hpp"
54 #include "Teuchos_StandardFunctionObjects.hpp"
77 static const bool& getShowIfDefaultValue(){
78 static const bool SHOW_IF_DEFAULT_VALUE =
true;
79 return SHOW_IF_DEFAULT_VALUE;
97 bool showIf=getShowIfDefaultValue());
110 bool showIf=getShowIfDefaultValue());
123 bool showIf=getShowIfDefaultValue());
136 bool showIf=getShowIfDefaultValue());
149 virtual bool getDependeeState()
const = 0;
154 bool isDependentVisible()
const;
157 bool getShowIf()
const;
177 bool dependentVisible_;
225 virtual void evaluate() = 0;
315 const std::string& value,
352 bool getDependeeState()
const;
360 std::string getTypeAttributeValue()
const;
370 void validateDep()
const;
466 bool getDependeeState()
const;
474 std::string getTypeAttributeValue()
const;
484 void validateDep()
const;
579 bool getDependeeState()
const;
587 std::string getTypeAttributeValue()
const;
795 T value = getFirstDependeeValue<T>();
796 if(!func_.is_null()){
797 value = func_->runFunction(value);
811 return func_.getConst();
820 "The dependee of a " <<
821 "Number Visual Dependency must the same type as the dependency's " <<
822 "template type!" << std::endl <<
823 "Type Encountered: " << dependee->
getAny().
typeName() << std::endl <<
864 template<
class DependeeType,
class DependentType>
938 DependeeType newAmount,
964 template<
class DependeeType,
class DependentType>
973 template<
class DependeeType,
class DependentType>
982 template<
class DependeeType,
class DependentType>
985 typeid(DependeeType) != getFirstDependee()->getAny().type(),
987 "Ay no! The dependee parameter types don't match." << std::endl <<
990 "Dependee Parameter Type: " << getFirstDependee()->getAny().
typeName()
991 << std::endl << std::endl);
994 template<
class DependeeType,
class DependentType>
996 DependeeType newAmount = Dependency::getFirstDependeeValue<DependeeType>();
997 if(!this->getFunctionObject().
is_null()){
998 newAmount = this->getFunctionObject()->runFunction(newAmount);
1003 getBadDependentValueErrorMessage());
1006 Dependency::ParameterEntryList::iterator it = this->getDependents().begin();
1007 it != this->getDependents().end();
1010 modifyArray(newAmount, *it);
1037 template<
class DependeeType,
class DependentType>
1101 template<
class DependeeType,
class DependentType>
1111 template<
class DependeeType,
class DependentType>
1122 template<
class DependeeType,
class DependentType>
1127 return "NumberArrayLengthDependency(" +
1132 template <
class DependeeType,
class DependentType>
1138 any_cast<Array<DependentType> >(dependentToModify->
getAny());
1143 i<originalArray.
size() && i<newAmount;
1146 newArray[i] = originalArray[i];
1149 dependentToModify->
setValue(newArray,
1153 template<
class DependeeType,
class DependentType>
1156 std::ostringstream os;
1158 "Ruh Roh Shaggy! Looks like a dependency tried to set the length "
1159 "of the Array(s) to a negative number. Silly. You can't have "
1160 "an Array with a negative length!" << std::endl << std::endl <<
1161 "Error:" << std::endl <<
1162 "An attempt was made to set the length of an Array to a negative "
1163 "number by a NumberArrayLengthDependency" << std::endl << std::endl;
1167 template<
class DependeeType,
class DependentType>
1174 Dependency::ConstParameterEntryList::const_iterator it =
1175 this->getDependents().begin();
1176 it != this->getDependents().end();
1182 "Ay no! The dependent parameter types don't match." << std::endl <<
1183 "Dependent Template Type: " <<
1185 "Dependent Parameter Type: " <<
1186 (*it)->getAny().typeName() << std::endl << std::endl);
1195 template<
class DependeeType,
class DependentType>
1213 template<
class DependeeType,
class DependentType>
1257 typedef std::map<std::string, RCP<const ParameterEntryValidator> >
1263 typedef std::pair<std::string, RCP<const ParameterEntryValidator> >
1335 std::string getTypeAttributeValue()
const;
1344 void validateDep()
const;
1470 std::string getTypeAttributeValue()
const;
1479 void validateDep()
const;
1563 typedef std::map<Range, RCP<const ParameterEntryValidator> >
1569 typedef std::pair<Range, RCP<const ParameterEntryValidator> >
1622 return rangesAndValidators_;
1627 return defaultValidator_;
1684 rangesAndValidators_(rangesAndValidators),
1685 defaultValidator_(defaultValidator)
1697 rangesAndValidators_(rangesAndValidators),
1698 defaultValidator_(defaultValidator)
1712 typename RangeToValidatorMap::const_iterator it;
1713 T dependeeValue = getFirstDependeeValue<T>();
1715 it = rangesAndValidators_.begin();
1716 it != rangesAndValidators_.end();
1719 T min = it->first.first;
1720 T max = it->first.second;
1721 if(dependeeValue >= min && dependeeValue <max){
1722 setDependentsToValidator(it->second);
1726 setDependentsToValidator(defaultValidator_);
1734 "The dependee of a RangeValidatorDependency must be the same type as " <<
1735 "The RangeValidatorDependency template type!" << std::endl <<
1736 "Dependee Type: " << dependee->
getAny().
typeName() << std::endl <<
1740 rangesAndValidators_.size() < 1,
1742 "The rangesAndValidators map RangeValidatorDependency "
1743 "must have at least one entry!" << std::endl << std::endl);
1745 typename RangeToValidatorMap::const_iterator it =
1746 rangesAndValidators_.begin();
1751 for(; it!=rangesAndValidators_.end(); ++it){
1754 "Ay no! All of the validators in a RangeValidatorDependency "
1755 "must have the same type.");
1757 it->first.first > it->first.second,
1759 "The Range " << it->first.first <<
" to " << it->first.second <<
1760 " is invalid. The min can't be greater than the max, you silly goose!"
1767 typeid(*rawValidatorPtr) !=
typeid(*defaultValidator_),
1769 "Ay no! The default validator of a RangeValidatorDependency "
1770 "must have the same type as the validators in rangesAndValidators map."
1779 typename ParameterEntryList::const_iterator it;
1781 it = getDependents().begin();
1782 it != getDependents().end();
1785 (*it)->setValidator(toSet);
1821 dummyRange, dummyValidator));
1832 template<
class DependeeType,
class DependentType>
1892 template<
class DependeeType,
class DependentType>
1899 Dependency::ConstParameterEntryList::const_iterator it =
1900 this->getDependents().begin();
1901 it != this->getDependents().end();
1907 "Ay no! The dependent parameter types don't match." << std::endl <<
1908 "Dependent Template Type: " <<
1910 "Dependent Parameter Type: " <<
1911 (*it)->getAny().typeName() << std::endl << std::endl);
1923 template<
class DependeeType,
class DependentType>
1985 template<
class DependeeType,
class DependentType>
1991 dependee, dependent, func)
1996 template<
class DependeeType,
class DependentType>
2002 dependee, dependents, func)
2008 template<
class DependeeType,
class DependentType>
2013 return "TwoDRowDependency(" +
2018 template <
class DependeeType,
class DependentType>
2021 DependeeType newAmount,
2025 any_cast<TwoDArray<DependentType> >(dependentToModify->
getAny());
2027 dependentToModify->
setValue(originalArray,
2031 template<
class DependeeType,
class DependentType>
2034 std::ostringstream os;
2036 "Ruh Roh Shaggy! Looks like a dependency tried to set the number of "
2037 "rows in TwoDArray(s) to a negative number. Silly. You can't have "
2038 "a TwoDArray with a negative number of rows!" << std::endl << std::endl <<
2039 "Error:" << std::endl <<
2040 "An attempt was made to set the number of rows of a TwoDArray to a negative "
2041 "number by a TwoDRowDependency" << std::endl << std::endl;
2050 template<
class DependeeType,
class DependentType>
2068 template<
class DependeeType,
class DependentType>
2086 template<
class DependeeType,
class DependentType>
2148 template<
class DependeeType,
class DependentType>
2154 dependee, dependent, func)
2159 template<
class DependeeType,
class DependentType>
2165 dependee, dependents, func)
2171 template<
class DependeeType,
class DependentType>
2176 return "TwoDColDependency(" +
2181 template <
class DependeeType,
class DependentType>
2184 DependeeType newAmount,
2188 any_cast<TwoDArray<DependentType> >(dependentToModify->
getAny());
2190 dependentToModify->
setValue(originalArray,
2194 template<
class DependeeType,
class DependentType>
2197 std::ostringstream os;
2199 "Ruh Roh Shaggy! Looks like a dependency tried to set the number of "
2200 "cols in TwoDArray(s) to a negative number. Silly. You can't have "
2201 "a TwoDArray with a negative number of cols!" << std::endl << std::endl <<
2202 "Error:" << std::endl <<
2203 "An attempt was made to set the number of columns of a TwoDArrayArray to a negative "
2204 "number by a TwoDColDependency" << std::endl << std::endl;
2213 template<
class DependeeType,
class DependentType>
2231 template<
class DependeeType,
class DependentType>
2244 #endif //TEUCHOS_STANDARDDEPENDCIES_HPP_