10#ifndef TEUCHOS_STANDARDDEPENDCIES_HPP_
11#define TEUCHOS_STANDARDDEPENDCIES_HPP_
17#include "Teuchos_Dependency.hpp"
18#include "Teuchos_StandardParameterEntryValidators.hpp"
20#include "Teuchos_StandardFunctionObjects.hpp"
43 static const bool& getShowIfDefaultValue(){
63 bool showIf=getShowIfDefaultValue());
76 bool showIf=getShowIfDefaultValue());
89 bool showIf=getShowIfDefaultValue());
102 bool showIf=getShowIfDefaultValue());
120 bool isDependentVisible()
const;
123 bool getShowIf()
const;
143 bool dependentVisible_;
281 const std::string& value,
318 bool getDependeeState()
const;
326 std::string getTypeAttributeValue()
const;
336 void validateDep()
const;
432 bool getDependeeState()
const;
440 std::string getTypeAttributeValue()
const;
450 void validateDep()
const;
545 bool getDependeeState()
const;
553 std::string getTypeAttributeValue()
const;
762 if(!func_.is_null()){
763 value = func_->runFunction(value);
784 !dependee->isType<
T>(),
786 "The dependee of a " <<
787 "Number Visual Dependency must the same type as the dependency's " <<
788 "template type!" << std::endl <<
789 "Type Encountered: " << dependee->getAny().typeName() << std::endl <<
830template<
class DependeeType,
class DependentType>
930template<
class DependeeType,
class DependentType>
939template<
class DependeeType,
class DependentType>
948template<
class DependeeType,
class DependentType>
951 typeid(
DependeeType) != getFirstDependee()->getAny().type(),
953 "Ay no! The dependee parameter types don't match." << std::endl <<
956 "Dependee Parameter Type: " << getFirstDependee()->getAny().
typeName()
957 << std::endl << std::endl);
960template<
class DependeeType,
class DependentType>
963 if(!this->getFunctionObject().
is_null()){
969 getBadDependentValueErrorMessage());
972 Dependency::ParameterEntryList::iterator
it = this->getDependents().begin();
973 it != this->getDependents().end();
1003template<
class DependeeType,
class DependentType>
1067template<
class DependeeType,
class DependentType>
1077template<
class DependeeType,
class DependentType>
1088template<
class DependeeType,
class DependentType>
1093 return "NumberArrayLengthDependency(" +
1098template <
class DependeeType,
class DependentType>
1119template<
class DependeeType,
class DependentType>
1122 std::ostringstream os;
1124 "Ruh Roh Shaggy! Looks like a dependency tried to set the length "
1125 "of the Array(s) to a negative number. Silly. You can't have "
1126 "an Array with a negative length!" << std::endl << std::endl <<
1127 "Error:" << std::endl <<
1128 "An attempt was made to set the length of an Array to a negative "
1129 "number by a NumberArrayLengthDependency" << std::endl << std::endl;
1133template<
class DependeeType,
class DependentType>
1140 Dependency::ConstParameterEntryList::const_iterator
it =
1141 this->getDependents().begin();
1142 it != this->getDependents().end();
1148 "Ay no! The dependent parameter types don't match." << std::endl <<
1149 "Dependent Template Type: " <<
1151 "Dependent Parameter Type: " <<
1152 (*it)->getAny().typeName() << std::endl << std::endl);
1161template<
class DependeeType,
class DependentType>
1179template<
class DependeeType,
class DependentType>
1223 typedef std::map<std::string, RCP<const ParameterEntryValidator> >
1229 typedef std::pair<std::string, RCP<const ParameterEntryValidator> >
1301 std::string getTypeAttributeValue()
const;
1310 void validateDep()
const;
1436 std::string getTypeAttributeValue()
const;
1445 void validateDep()
const;
1529 typedef std::map<Range, RCP<const ParameterEntryValidator> >
1535 typedef std::pair<Range, RCP<const ParameterEntryValidator> >
1588 return rangesAndValidators_;
1593 return defaultValidator_;
1678 typename RangeToValidatorMap::const_iterator
it;
1681 it = rangesAndValidators_.begin();
1682 it != rangesAndValidators_.end();
1685 T min =
it->first.first;
1686 T max =
it->first.second;
1688 setDependentsToValidator(
it->second);
1692 setDependentsToValidator(defaultValidator_);
1700 "The dependee of a RangeValidatorDependency must be the same type as " <<
1701 "The RangeValidatorDependency template type!" << std::endl <<
1702 "Dependee Type: " << dependee->getAny().typeName() << std::endl <<
1706 rangesAndValidators_.size() < 1,
1708 "The rangesAndValidators map RangeValidatorDependency "
1709 "must have at least one entry!" << std::endl << std::endl);
1711 typename RangeToValidatorMap::const_iterator
it =
1712 rangesAndValidators_.begin();
1717 for(;
it!=rangesAndValidators_.end(); ++
it){
1720 "Ay no! All of the validators in a RangeValidatorDependency "
1721 "must have the same type.");
1723 it->first.first >
it->first.second,
1725 "The Range " <<
it->first.first <<
" to " <<
it->first.second <<
1726 " is invalid. The min can't be greater than the max, you silly goose!"
1735 "Ay no! The default validator of a RangeValidatorDependency "
1736 "must have the same type as the validators in rangesAndValidators map."
1745 typename ParameterEntryList::const_iterator
it;
1747 it = getDependents().begin();
1748 it != getDependents().end();
1751 (*it)->setValidator(
toSet);
1798template<
class DependeeType,
class DependentType>
1858template<
class DependeeType,
class DependentType>
1865 Dependency::ConstParameterEntryList::const_iterator
it =
1866 this->getDependents().begin();
1867 it != this->getDependents().end();
1873 "Ay no! The dependent parameter types don't match." << std::endl <<
1874 "Dependent Template Type: " <<
1876 "Dependent Parameter Type: " <<
1877 (*it)->getAny().typeName() << std::endl << std::endl);
1889template<
class DependeeType,
class DependentType>
1951template<
class DependeeType,
class DependentType>
1962template<
class DependeeType,
class DependentType>
1974template<
class DependeeType,
class DependentType>
1979 return "TwoDRowDependency(" +
1984template <
class DependeeType,
class DependentType>
1997template<
class DependeeType,
class DependentType>
2000 std::ostringstream os;
2002 "Ruh Roh Shaggy! Looks like a dependency tried to set the number of "
2003 "rows in TwoDArray(s) to a negative number. Silly. You can't have "
2004 "a TwoDArray with a negative number of rows!" << std::endl << std::endl <<
2005 "Error:" << std::endl <<
2006 "An attempt was made to set the number of rows of a TwoDArray to a negative "
2007 "number by a TwoDRowDependency" << std::endl << std::endl;
2016template<
class DependeeType,
class DependentType>
2034template<
class DependeeType,
class DependentType>
2052template<
class DependeeType,
class DependentType>
2114template<
class DependeeType,
class DependentType>
2125template<
class DependeeType,
class DependentType>
2137template<
class DependeeType,
class DependentType>
2142 return "TwoDColDependency(" +
2147template <
class DependeeType,
class DependentType>
2160template<
class DependeeType,
class DependentType>
2163 std::ostringstream os;
2165 "Ruh Roh Shaggy! Looks like a dependency tried to set the number of "
2166 "cols in TwoDArray(s) to a negative number. Silly. You can't have "
2167 "a TwoDArray with a negative number of cols!" << std::endl << std::endl <<
2168 "Error:" << std::endl <<
2169 "An attempt was made to set the number of columns of a TwoDArrayArray to a negative "
2170 "number by a TwoDColDependency" << std::endl << std::endl;
2179template<
class DependeeType,
class DependentType>
2197template<
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.
An abstract base class for all dependencies which modify the dimensional attributes of an Array param...
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...
A BoolValidatorDependency says the following about the relationship between two parameters: Dependeni...
A bool visual dependency says the following about the relationship between two elements in a Paramete...
A condition visual dependency says the following about the relationship between elements in a Paramet...
This class represents a depndency between elements in a Parameter List.
std::set< RCP< ParameterEntry >, RCPComp > ParameterEntryList
A list of Dependees.
std::set< RCP< const ParameterEntry >, RCPConstComp > ConstParameterEntryList
A list of dependents.
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.
bool is_null() const
Returns true if the underlying pointer is null.
bool nonnull(const RCP< T > &p)
Returns true if p.get()!=NULL.
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 StringValidatorDependency says the following about the relationship between two parameters: Depende...
std::pair< std::string, RCP< const ParameterEntryValidator > > ValueToValidatorPair
Conveniece typedef.
std::map< std::string, RCP< const ParameterEntryValidator > > ValueToValidatorMap
Conveniece typedef.
A string visual dependency says the following about the relationship between two elements in a Parame...
Array< std::string > ValueList
A dependency in which some attribute of a TwoDArray in a parameter depends on the value of another pa...
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 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
Default traits class that just returns typeid(T).name().
static std::string name()
An abstract base class for all validator dependencies.
virtual void evaluate()=0
An abstract parent class for all visual dependencies.
virtual bool getDependeeState() const =0
Get the state of the dependee in order to evaluate the dependency.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
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.
This structure defines some basic traits for the ordinal field type.
This structure defines some basic traits for a scalar field type.
static T zero()
Returns representation of zero for this scalar type.