44 #ifndef TEUCHOS_STANDARDDEPENDCIES_HPP_ 45 #define TEUCHOS_STANDARDDEPENDCIES_HPP_ 78 static const bool SHOW_IF_DEFAULT_VALUE =
true;
79 return SHOW_IF_DEFAULT_VALUE;
97 bool showIf=getShowIfDefaultValue());
109 ParameterEntryList dependents,
110 bool showIf=getShowIfDefaultValue());
121 ConstParameterEntryList dependees,
123 bool showIf=getShowIfDefaultValue());
134 ConstParameterEntryList dependees,
135 ParameterEntryList dependents,
136 bool showIf=getShowIfDefaultValue());
149 virtual bool getDependeeState()
const = 0;
154 bool isDependentVisible()
const;
157 bool getShowIf()
const;
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>
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> >
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();
1749 for(; it!=rangesAndValidators_.end(); ++it){
1752 "Ay no! All of the validators in a RangeValidatorDependency " 1753 "must have the same type.");
1755 it->first.first > it->first.second,
1757 "The Range " << it->first.first <<
" to " << it->first.second <<
1758 " is invalid. The min can't be greater than the max, you silly goose!" 1765 typeid(*firstValidator) !=
typeid(*defaultValidator_),
1767 "Ay no! The default validator of a RangeValidatorDependency " 1768 "must have the same type as the validators in rangesAndValidators map." 1777 typename ParameterEntryList::const_iterator it;
1779 it = getDependents().begin();
1780 it != getDependents().end();
1783 (*it)->setValidator(toSet);
1819 dummyRange, dummyValidator));
1830 template<
class DependeeType,
class DependentType>
1890 template<
class DependeeType,
class DependentType>
1897 Dependency::ConstParameterEntryList::const_iterator it =
1898 this->getDependents().begin();
1899 it != this->getDependents().end();
1905 "Ay no! The dependent parameter types don't match." << std::endl <<
1906 "Dependent Template Type: " <<
1908 "Dependent Parameter Type: " <<
1909 (*it)->getAny().typeName() << std::endl << std::endl);
1921 template<
class DependeeType,
class DependentType>
1983 template<
class DependeeType,
class DependentType>
1989 dependee, dependent, func)
1994 template<
class DependeeType,
class DependentType>
2000 dependee, dependents, func)
2006 template<
class DependeeType,
class DependentType>
2011 return "TwoDRowDependency(" +
2016 template <
class DependeeType,
class DependentType>
2019 DependeeType newAmount,
2025 dependentToModify->
setValue(originalArray,
2029 template<
class DependeeType,
class DependentType>
2032 std::ostringstream os;
2034 "Ruh Roh Shaggy! Looks like a dependency tried to set the number of " 2035 "rows in TwoDArray(s) to a negative number. Silly. You can't have " 2036 "a TwoDArray with a negative number of rows!" << std::endl << std::endl <<
2037 "Error:" << std::endl <<
2038 "An attempt was made to set the number of rows of a TwoDArray to a negative " 2039 "number by a TwoDRowDependency" << std::endl << std::endl;
2048 template<
class DependeeType,
class DependentType>
2066 template<
class DependeeType,
class DependentType>
2084 template<
class DependeeType,
class DependentType>
2146 template<
class DependeeType,
class DependentType>
2152 dependee, dependent, func)
2157 template<
class DependeeType,
class DependentType>
2163 dependee, dependents, func)
2169 template<
class DependeeType,
class DependentType>
2174 return "TwoDColDependency(" +
2179 template <
class DependeeType,
class DependentType>
2182 DependeeType newAmount,
2188 dependentToModify->
setValue(originalArray,
2192 template<
class DependeeType,
class DependentType>
2195 std::ostringstream os;
2197 "Ruh Roh Shaggy! Looks like a dependency tried to set the number of " 2198 "cols in TwoDArray(s) to a negative number. Silly. You can't have " 2199 "a TwoDArray with a negative number of cols!" << std::endl << std::endl <<
2200 "Error:" << std::endl <<
2201 "An attempt was made to set the number of colums of a TwoDArrayArray to a negative " 2202 "number by a TwoDColDependency" << std::endl << std::endl;
2211 template<
class DependeeType,
class DependentType>
2229 template<
class DependeeType,
class DependentType>
2242 #endif //TEUCHOS_STANDARDDEPENDCIES_HPP_
A dependency in which the number of rows in a parameter with a TwoDArray depends on the value of anot...
RCP< const SimpleFunctionObject< DependeeType > > func_
The function used to calculate the amount by which an arrays dimensional attribute should be modified...
std::string typeName(const T &t)
Template function for returning the concrete type name of a passed-in object.
RCP< ParameterEntryValidator > defaultValidator_
The default validator to be used if a request is made for a value that does not appear in the valuesA...
static RCP< T > getDummyObject()
Retrieves a dummy object of type T.
A BoolValidatorDependency says the following about the relationship between two parameters: Dependeni...
std::string getTypeAttributeValue() const
void setDependentsToValidator(RCP< const ParameterEntryValidator > toSet)
std::pair< std::string, RCP< const ParameterEntryValidator > > ValueToValidatorPair
Conveniece typedef.
void setValue(T value, bool isDefault=false, const std::string &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Templated set method that uses the input value type to determine the type of parameter.
An abstract parent class for all visual dependencies.
A string visual depdencies says the following about the relationship between two elements in a Parame...
RCP< const ParameterEntryValidator > trueValidator_
The validators to be used when the dependee is either true or false.
A bool visual dependency says the following about the relationship between two elements in a Paramete...
A dependency in which the number of rows in a parameter with a TwoDArray depends on the value of anot...
bool dependentVisible_
Whether or not the dependent is currently visible.
std::set< RCP< ParameterEntry >, RCPComp > ParameterEntryList
A list of Dependees.
bool nonnull(const std::shared_ptr< T > &p)
Returns true if p.get()!=NULL.
This object is held as the "value" in the Teuchos::ParameterList std::map.
RCP< const ParameterEntryValidator > defaultValidator_
NumberArrayLengthDependency(RCP< const ParameterEntry > dependee, RCP< ParameterEntry > dependent, RCP< const SimpleFunctionObject< DependeeType > > func=null)
Constructs a NumberArrayLengthDependency.
virtual void validateDep() const
StringValidatorDependency::ValueToValidatorMap valuesAndValidators
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
RCP< const ParameterEntryValidator > getDefaultValidator() const
void modifyArray(DependeeType newAmount, RCP< ParameterEntry > dependentToModify)
std::map< std::string, RCP< const ParameterEntryValidator > > ValueToValidatorMap
Conveniece typedef.
virtual void modifyArray(DependeeType newAmount, RCP< ParameterEntry > dependentToModify)=0
Modifies a particular attribute of the array according to the specific semantics of the dependency...
ArrayModifierDependency(RCP< const ParameterEntry > dependee, RCP< ParameterEntry > dependent, RCP< const SimpleFunctionObject< DependeeType > > func=null)
Constructs an ArrayModifierDependency.
std::string getBadDependentValueErrorMessage() const
Array< std::string > ValueList
This class represents a depndency between elements in a Parameter List.
This structure defines some basic traits for a scalar field type.
A RangeValidatorDependency says the following about the relationship between two parameters: Dependen...
bool showIf_
Whether or not to show the dependent if the dependee is set to the value.
RCP< const Condition > condition_
The Condition to determine whether or not the dependent is displayed.
std::string getTypeAttributeValue() const
A thin wrapper around the Array class which causes it to be interpurted as a 2D Array.
std::string getTypeAttributeValue() const
TwoDRowDependency(RCP< const ParameterEntry > dependee, RCP< ParameterEntry > dependent, RCP< const SimpleFunctionObject< DependeeType > > func=null)
Constructs a TwoDRowDependency.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
ValueToValidatorMap valuesAndValidators_
A map associating particular dependee values with validators that could be placed on the dependent...
const RangeToValidatorMap & getRangeToValidatorMap() const
TwoDArrayModifierDependency(RCP< const ParameterEntry > dependee, RCP< ParameterEntry > dependent, RCP< const SimpleFunctionObject< DependeeType > > func=null)
Constructs a TwoDArrayModifierDependency.
RCP< const SimpleFunctionObject< DependeeType > > getFunctionObject() const
Retrieves the function being used to calculate the amount by which an arrays dimensional attribute sh...
virtual void validateDep() const
void resizeCols(size_type numberOfCols)
Changes the number of rows in the matrix.
A NumberArrayLengthDependency says the following about the relationship between two parameters: The l...
void resizeRows(size_type numberOfRows)
Changes the number of rows in the matrix.
This structure defines some basic traits for the ordinal field type.
TwoDArrayModifierDependency(RCP< const ParameterEntry > dependee, Dependency::ParameterEntryList dependents, RCP< const SimpleFunctionObject< DependeeType > > func=null)
Constructs a TwoDArrayModifierDependency.
void modifyArray(DependeeType newAmount, RCP< ParameterEntry > dependentToModify)
RCP< const ParameterEntryValidator > validator() const
Return the (optional) validator object.
TwoDColDependency(RCP< const ParameterEntry > dependee, RCP< ParameterEntry > dependent, RCP< const SimpleFunctionObject< DependeeType > > func=null)
Constructs a TwoDColDependency.
#define TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT
bool isType() const
Test the type of the data being contained.
const std::type_info & type() const
Return the type of value being stored.
any & getAny(bool activeQry=true)
Direct access to the Teuchos::any data value underlying this object. The bool argument activeQry (def...
bool getDependeeState() const
Get the state of the dependee in order to evaluate the dependency.
std::string getTypeAttributeValue() const
virtual void validateDep() const
NumberVisualDependency(RCP< const ParameterEntry > dependee, RCP< ParameterEntry > dependent, bool showIf=true, RCP< SimpleFunctionObject< T > > func=null)
Constructs a NumberVisualDependency.
Defines basic traits for the ordinal field type.
Default traits class that just returns typeid(T).name().
Class for retrieving a dummy object of type T.
A StringValidatorDependency says the following about the relationship between two parameters: Depende...
std::string typeName() const
Return the name of the type.
RangeValidatorDependency(RCP< const ParameterEntry > dependee, RCP< ParameterEntry > dependent, RangeToValidatorMap rangesAndValidators, RCP< const ParameterEntryValidator > defaultValidator=null)
Constructs a RangeValidatorDependency.
An abstract base class for all dependencies which modify the dimensional attributes of an Array param...
std::string getBadDependentValueErrorMessage() const
Defines basic traits for the scalar field type.
static T zero()
Returns representation of zero for this scalar type.
std::string getBadDependentValueErrorMessage() const
An abstract base class for all validator dependencies.
std::string docString() const
Return the (optional) documentation std::string.
RCP< const SimpleFunctionObject< T > > getFunctionObject() const
Const version of function getter.
Smart reference counting pointer class for automatic garbage collection.
A condition visual dependency says the following about the relationship between elements in a Paramet...
virtual std::string getBadDependentValueErrorMessage() const =0
Returns the error message that should be displayed if the dependent has taken on a value that...
std::pair< Range, RCP< const ParameterEntryValidator > > RangeValidatorPair
Convenience typedef.
void modifyArray(DependeeType newAmount, RCP< ParameterEntry > dependentToModify)
std::pair< T, T > Range
Convenience typedef.
RCP< SimpleFunctionObject< T > > func_
the function used to determine the visibility of the dependent.
RangeToValidatorMap rangesAndValidators_
A map associating ranges with validators.
static const bool & getShowIfDefaultValue()
A number visual dependency says the following about the relationship between two elements in a Parame...
std::string getTypeAttributeValue() const
A dependency in which some attribute of a TwoDArray in a parameter depends on the value of another pa...
std::map< Range, RCP< const ParameterEntryValidator > > RangeToValidatorMap
Convenience typedef.
Standard Conditions to be used.
static std::string name()