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());
177 bool dependentVisible_;
315 const std::string& value,
796 if(!func_.is_null()){
797 value = func_->runFunction(value);
818 !dependee->isType<T>(),
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 <<
864template<
class DependeeType,
class DependentType>
938 DependeeType newAmount,
964template<
class DependeeType,
class DependentType>
973template<
class DependeeType,
class DependentType>
982template<
class DependeeType,
class DependentType>
987 "Ay no! The dependee parameter types don't match." << std::endl <<
991 << std::endl << std::endl);
994template<
class DependeeType,
class DependentType>
1006 Dependency::ParameterEntryList::iterator it = this->
getDependents().begin();
1037template<
class DependeeType,
class DependentType>
1101template<
class DependeeType,
class DependentType>
1111template<
class DependeeType,
class DependentType>
1122template<
class DependeeType,
class DependentType>
1127 return "NumberArrayLengthDependency(" +
1132template <
class DependeeType,
class DependentType>
1143 i<originalArray.
size() && i<newAmount;
1146 newArray[i] = originalArray[i];
1149 dependentToModify->setValue(newArray,
1150 false, dependentToModify->docString(), dependentToModify->validator());
1153template<
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;
1167template<
class DependeeType,
class DependentType>
1174 Dependency::ConstParameterEntryList::const_iterator it =
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);
1195template<
class DependeeType,
class DependentType>
1213template<
class DependeeType,
class DependentType>
1257 typedef std::map<std::string, RCP<const ParameterEntryValidator> >
1263 typedef std::pair<std::string, RCP<const ParameterEntryValidator> >
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;
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."
1776void RangeValidatorDependency<T>::setDependentsToValidator(
1779 typename ParameterEntryList::const_iterator it;
1781 it = getDependents().begin();
1782 it != getDependents().end();
1785 (*it)->setValidator(toSet);
1821 dummyRange, dummyValidator));
1832template<
class DependeeType,
class DependentType>
1892template<
class DependeeType,
class DependentType>
1899 Dependency::ConstParameterEntryList::const_iterator it =
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);
1923template<
class DependeeType,
class DependentType>
1985template<
class DependeeType,
class DependentType>
1991 dependee, dependent, func)
1996template<
class DependeeType,
class DependentType>
2002 dependee, dependents, func)
2008template<
class DependeeType,
class DependentType>
2013 return "TwoDRowDependency(" +
2018template <
class DependeeType,
class DependentType>
2021 DependeeType newAmount,
2027 dependentToModify->setValue(originalArray,
2028 false, dependentToModify->docString(), dependentToModify->validator());
2031template<
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;
2050template<
class DependeeType,
class DependentType>
2068template<
class DependeeType,
class DependentType>
2086template<
class DependeeType,
class DependentType>
2148template<
class DependeeType,
class DependentType>
2154 dependee, dependent, func)
2159template<
class DependeeType,
class DependentType>
2165 dependee, dependents, func)
2171template<
class DependeeType,
class DependentType>
2176 return "TwoDColDependency(" +
2181template <
class DependeeType,
class DependentType>
2184 DependeeType newAmount,
2190 dependentToModify->setValue(originalArray,
2191 false, dependentToModify->docString(), dependentToModify->validator());
2194template<
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;
2213template<
class DependeeType,
class DependentType>
2231template<
class DependeeType,
class DependentType>
Defines basic traits for the ordinal field type.
Defines basic traits for the scalar field type.
Standard Conditions to be used.
ArrayModifierDependency(RCP< const ParameterEntry > dependee, RCP< ParameterEntry > dependent, RCP< const SimpleFunctionObject< DependeeType > > func=null)
Constructs an ArrayModifierDependency.
virtual void modifyArray(DependeeType newAmount, RCP< ParameterEntry > dependentToModify)=0
Modifies a particular attribute of the array according to the specific semantics of the dependency.
virtual std::string getBadDependentValueErrorMessage() const =0
Returns the error message that should be displayed if the dependent has taken on a value that,...
virtual void validateDep() const
RCP< const SimpleFunctionObject< DependeeType > > getFunctionObject() const
Retrieves the function being used to calculate the amount by which an arrays dimensional attribute sh...
Replacement for std::vector that is compatible with the Teuchos Memory Management classes.
A BoolValidatorDependency says the following about the relationship between two parameters: Dependeni...
BoolValidatorDependency(RCP< const ParameterEntry > dependee, RCP< ParameterEntry > dependent, RCP< const ParameterEntryValidator > trueValidator, RCP< const ParameterEntryValidator > falseValidator=null)
Constructs a BoolValidatorDependency.
std::string getTypeAttributeValue() const
RCP< const ParameterEntryValidator > getTrueValidator() const
Gets the true validator.
void validateDep() const
Validates the dependency to make sure it's valid/has been setup properly. If subclassing,...
RCP< const ParameterEntryValidator > getFalseValidator() const
Gets the false validator.
A bool visual dependency says the following about the relationship between two elements in a Paramete...
bool getDependeeState() const
std::string getTypeAttributeValue() const
BoolVisualDependency(RCP< const ParameterEntry > dependee, RCP< ParameterEntry > dependent, bool showIf=true)
A condition visual dependency says the following about the relationship between elements in a Paramet...
std::string getTypeAttributeValue() const
bool getDependeeState() const
ConditionVisualDependency(RCP< const Condition > condition, RCP< ParameterEntry > dependent, bool showIf=true)
RCP< const Condition > getCondition() const
Gets the condition being used in this dependency.
ParameterEntryList & getDependents()
Gets the dependents of the dependency.
Dependency(ConstParameterEntryList dependees, ParameterEntryList dependents)
Constructs a Dependency.
std::set< RCP< ParameterEntry >, RCPComp > ParameterEntryList
A list of Dependees.
S getFirstDependeeValue() const
Convienence function. Returns the first dependee in the list of dependees.
std::set< RCP< const ParameterEntry >, RCPConstComp > ConstParameterEntryList
A list of dependents.
RCP< const ParameterEntry > getFirstDependee() const
Gets the first dependee in the dependees list. This is a convience function.
static RCP< BoolValidatorDependency > getDummyObject()
Retrieves a dummy object of type BoolValidatorDependency.
static RCP< BoolVisualDependency > getDummyObject()
Retrieves a dummy object of type BoolVisualDependency.
static RCP< ConditionVisualDependency > getDummyObject()
Retrieves a dummy object of type ConditionVisualDependency.
static RCP< NumberArrayLengthDependency< DependeeType, DependentType > > getDummyObject()
Retrieves a dummy object of type NumberArrayLengthDependency.
static RCP< NumberVisualDependency< T > > getDummyObject()
Retrieves a dummy object of type NumberVisualDependency.
static RCP< RangeValidatorDependency< T > > getDummyObject()
Retrieves a dummy object of type RangeValidatorDependency.
static RCP< StringValidatorDependency > getDummyObject()
Retrieves a dummy object of type StringValidatorDependency.
static RCP< StringVisualDependency > getDummyObject()
Retrieves a dummy object of type StringVisualDependency.
static RCP< TwoDColDependency< DependeeType, DependentType > > getDummyObject()
Retrieves a dummy object of type NumberArrayLengthDependency.
static RCP< TwoDRowDependency< DependeeType, DependentType > > getDummyObject()
Retrieves a dummy object of type NumberArrayLengthDependency.
Class for retrieving a dummy object of type T.
static RCP< T > getDummyObject()
Retrieves a dummy object of type T.
A NumberArrayLengthDependency says the following about the relationship between two parameters: The l...
virtual void validateDep() const
std::string getTypeAttributeValue() const
std::string getBadDependentValueErrorMessage() const
NumberArrayLengthDependency(RCP< const ParameterEntry > dependee, RCP< ParameterEntry > dependent, RCP< const SimpleFunctionObject< DependeeType > > func=null)
Constructs a NumberArrayLengthDependency.
void modifyArray(DependeeType newAmount, RCP< ParameterEntry > dependentToModify)
A number visual dependency says the following about the relationship between two elements in a Parame...
bool getDependeeState() const
Get the state of the dependee in order to evaluate the dependency.
NumberVisualDependency(RCP< const ParameterEntry > dependee, RCP< ParameterEntry > dependent, bool showIf=true, RCP< SimpleFunctionObject< T > > func=null)
Constructs a NumberVisualDependency.
std::string getTypeAttributeValue() const
RCP< const SimpleFunctionObject< T > > getFunctionObject() const
Const version of function getter.
Abstract interface for an object that can validate a ParameterEntry's value.
This object is held as the "value" in the Teuchos::ParameterList std::map.
Smart reference counting pointer class for automatic garbage collection.
RCP< const T > getConst() const
Return an RCP<const T> version of *this.
T * get() const
Get the raw C++ pointer to the underlying object.
A RangeValidatorDependency says the following about the relationship between two parameters: Dependen...
std::pair< Range, RCP< const ParameterEntryValidator > > RangeValidatorPair
Convenience typedef.
const RangeToValidatorMap & getRangeToValidatorMap() const
RangeValidatorDependency(RCP< const ParameterEntry > dependee, RCP< ParameterEntry > dependent, RangeToValidatorMap rangesAndValidators, RCP< const ParameterEntryValidator > defaultValidator=null)
Constructs a RangeValidatorDependency.
RCP< const ParameterEntryValidator > getDefaultValidator() const
std::map< Range, RCP< const ParameterEntryValidator > > RangeToValidatorMap
Convenience typedef.
std::string getTypeAttributeValue() const
std::pair< T, T > Range
Convenience typedef.
A simple function object that applies a given operand to a spcified arguement using a specific operat...
A StringValidatorDependency says the following about the relationship between two parameters: Depende...
void validateDep() const
Validates the dependency to make sure it's valid/has been setup properly. If subclassing,...
std::string getTypeAttributeValue() const
const ValueToValidatorMap & getValuesAndValidators() const
retrieve a const reference to the ValueToValidator map being used by this StringValidatorDependency
RCP< const ParameterEntryValidator > getDefaultValidator() const
std::pair< std::string, RCP< const ParameterEntryValidator > > ValueToValidatorPair
Conveniece typedef.
StringValidatorDependency(RCP< const ParameterEntry > dependee, RCP< ParameterEntry > dependent, ValueToValidatorMap valuesAndValidators, RCP< ParameterEntryValidator > defaultValidator=null)
Constructs a StringValidatorDependency.
std::map< std::string, RCP< const ParameterEntryValidator > > ValueToValidatorMap
Conveniece typedef.
A string visual depdencies says the following about the relationship between two elements in a Parame...
Array< std::string > ValueList
const ValueList & getValues() const
get the List of values the dependee will be checked against.
StringVisualDependency(RCP< const ParameterEntry > dependee, RCP< ParameterEntry > dependent, std::string value, bool showIf=true)
Constructs a StringVisualDependency.
std::string getTypeAttributeValue() const
bool getDependeeState() const
virtual void validateDep() const
TwoDArrayModifierDependency(RCP< const ParameterEntry > dependee, Dependency::ParameterEntryList dependents, RCP< const SimpleFunctionObject< DependeeType > > func=null)
Constructs a TwoDArrayModifierDependency.
TwoDArrayModifierDependency(RCP< const ParameterEntry > dependee, RCP< ParameterEntry > dependent, RCP< const SimpleFunctionObject< DependeeType > > func=null)
Constructs a TwoDArrayModifierDependency.
A thin wrapper around the Array class which causes it to be interpreted as a 2D Array.
void resizeRows(size_type numberOfRows)
Changes the number of rows in the matrix.
void resizeCols(size_type numberOfCols)
Changes the number of rows in the matrix.
A dependency in which the number of rows in a parameter with a TwoDArray depends on the value of anot...
TwoDColDependency(RCP< const ParameterEntry > dependee, RCP< ParameterEntry > dependent, RCP< const SimpleFunctionObject< DependeeType > > func=null)
Constructs a TwoDColDependency.
std::string getTypeAttributeValue() const
void modifyArray(DependeeType newAmount, RCP< ParameterEntry > dependentToModify)
std::string getBadDependentValueErrorMessage() const
A dependency in which the number of rows in a parameter with a TwoDArray depends on the value of anot...
void modifyArray(DependeeType newAmount, RCP< ParameterEntry > dependentToModify)
std::string getBadDependentValueErrorMessage() const
TwoDRowDependency(RCP< const ParameterEntry > dependee, RCP< ParameterEntry > dependent, RCP< const SimpleFunctionObject< DependeeType > > func=null)
Constructs a TwoDRowDependency.
std::string getTypeAttributeValue() const
static std::string name()
virtual void evaluate()=0
ValidatorDependency(RCP< const ParameterEntry > dependee, RCP< ParameterEntry > dependent)
Constructs a ValidatorDependency.
bool isDependentVisible() const
Determines whether or not the dependent is currently visible.
virtual bool getDependeeState() const =0
Get the state of the dependee in order to evaluate the dependency.
bool getShowIf() const
Get's the value of the showIf variable.
VisualDependency(RCP< const ParameterEntry > dependee, RCP< ParameterEntry > dependent, bool showIf=getShowIfDefaultValue())
Constructs a VisualDependency.
ValueType & any_cast(any &operand)
Used to extract the templated value held in Teuchos::any to a given value type.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
bool is_null(const std::shared_ptr< T > &p)
Returns true if p.get()==NULL.
bool nonnull(const std::shared_ptr< T > &p)
Returns true if p.get()!=NULL.
std::string typeName(const T &t)
Template function for returning the concrete type name of a passed-in object.
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.
static T zero()
Returns representation of zero for this ordinal type.
static T one()
Returns representation of one for this scalar type.
static T zero()
Returns representation of zero for this scalar type.