Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_StandardDependencies.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Teuchos: Common Tools Package
4 //
5 // Copyright 2004 NTESS and the Teuchos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef TEUCHOS_STANDARDDEPENDCIES_HPP_
11 #define TEUCHOS_STANDARDDEPENDCIES_HPP_
12 
17 #include "Teuchos_Dependency.hpp"
21 #include "Teuchos_ScalarTraits.hpp"
23 
24 
25 namespace Teuchos{
26 
27 
39 
40 public:
41 
43  static const bool& getShowIfDefaultValue(){
44  static const bool SHOW_IF_DEFAULT_VALUE = true;
45  return SHOW_IF_DEFAULT_VALUE;
46  }
47 
48 
51 
62  RCP<ParameterEntry> dependent,
63  bool showIf=getShowIfDefaultValue());
64 
75  ParameterEntryList dependents,
76  bool showIf=getShowIfDefaultValue());
77 
87  ConstParameterEntryList dependees,
88  RCP<ParameterEntry> dependent,
89  bool showIf=getShowIfDefaultValue());
90 
100  ConstParameterEntryList dependees,
101  ParameterEntryList dependents,
102  bool showIf=getShowIfDefaultValue());
103 
105 
107 
108 
115  virtual bool getDependeeState() const = 0;
116 
120  bool isDependentVisible() const;
121 
123  bool getShowIf() const;
124 
126 
129 
131  void evaluate();
132 
134 
135 private:
136 
139 
144 
149  bool showIf_;
150 
152 
153 };
154 
159 
160 public:
161 
164 
172  RCP<const ParameterEntry> dependee,
173  RCP<ParameterEntry> dependent);
174 
182  RCP<const ParameterEntry> dependee,
183  ParameterEntryList dependents);
184 
186 
189 
191  virtual void evaluate() = 0;
192 
194 
195 };
196 
211 
212 public:
213 
216 
221 
223 
226 
241  RCP<const ParameterEntry> dependee,
242  RCP<ParameterEntry> dependent,
243  std::string value,
244  bool showIf=true);
245 
260  RCP<const ParameterEntry> dependee,
261  RCP<ParameterEntry> dependent,
262  const ValueList& values,
263  bool showIf=true);
264 
279  RCP<const ParameterEntry> dependee,
281  const std::string& value,
282  bool showIf=true);
283 
299  RCP<const ParameterEntry> dependee,
301  const ValueList& values,
302  bool showIf=true);
303 
305 
308 
310  const ValueList& getValues() const;
311 
313 
316 
318  bool getDependeeState() const;
319 
321 
324 
326  std::string getTypeAttributeValue() const;
327 
329 
330 protected:
331 
334 
336  void validateDep() const;
337 
339 
340 private:
341 
344 
349 
351 
352 };
353 
354 
360 template<>
362 
363 public:
364 
367 
371  static RCP<StringVisualDependency> getDummyObject();
372 
374 
375 };
376 
377 
392 
393 public:
394 
397 
408  RCP<const ParameterEntry> dependee,
409  RCP<ParameterEntry> dependent,
410  bool showIf=true);
411 
422  RCP<const ParameterEntry> dependee,
424  bool showIf=true);
425 
427 
430 
432  bool getDependeeState() const;
433 
435 
438 
440  std::string getTypeAttributeValue() const;
441 
443 
444 protected:
445 
448 
450  void validateDep() const;
451 
453 
454 };
455 
456 
462 template<>
464 
465 public:
466 
469 
473  static RCP<BoolVisualDependency> getDummyObject();
474 
476 
477 };
478 
496 
497 public:
498 
501 
514  RCP<const Condition> condition,
515  RCP<ParameterEntry> dependent,
516  bool showIf=true);
517 
529  RCP<const Condition> condition,
531  bool showIf=true);
532 
534 
537 
539  RCP<const Condition> getCondition() const;
540 
543 
545  bool getDependeeState() const;
546 
548 
551 
553  std::string getTypeAttributeValue() const;
554 
556 
557 protected:
558 
561 
563  void validateDep() const {}
564 
566 
567 
568 private:
569 
572 
577 
579 
580 };
581 
582 
588 template<>
590 
591 public:
592 
595 
598  static RCP<ConditionVisualDependency> getDummyObject();
599 
601 
602 };
603 
604 
625 template <class T>
627 
628 public:
629 
632 
654  RCP<const ParameterEntry> dependee,
655  RCP<ParameterEntry> dependent,
656  bool showIf=true,
658 
680  RCP<const ParameterEntry> dependee,
681  ParameterEntryList dependents,
682  bool showIf=true,
684 
686 
689 
690  bool getDependeeState() const;
691 
693 
696 
698  std::string getTypeAttributeValue() const;
699 
701 
704 
707 
709 
710 protected:
711 
714 
716  void validateDep() const;
717 
719 
720 private:
721 
724 
730 
732  //
733 };
734 
735 template<class T>
737  RCP<const ParameterEntry> dependee,
738  RCP<ParameterEntry> dependent,
739  bool showIf,
741  :VisualDependency(dependee, dependent, showIf),
742  func_(func)
743 {
744  validateDep();
745 }
746 
747 template<class T>
749  RCP<const ParameterEntry> dependee,
750  ParameterEntryList dependents,
751  bool showIf,
753  :VisualDependency(dependee, dependents, showIf),
754  func_(func)
755 {
756  validateDep();
757 }
758 
759 template<class T>
761  T value = getFirstDependeeValue<T>();
762  if(!func_.is_null()){
763  value = func_->runFunction(value);
764  }
765  return value > ScalarTraits<T>::zero() ? true : false;
766 }
767 
768 template<class T>
770  return "NumberVisualDependency(" + TypeNameTraits<T>::name() + ")";
771 }
772 
773 template<class T>
776 {
777  return func_.getConst();
778 }
779 
780 template<class T>
782  RCP<const ParameterEntry> dependee = getFirstDependee();
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 <<
790  "Template Type: " << TypeNameTraits<T>::name() << std::endl <<
791  std::endl);
792 }
793 
794 
800 template<class T>
802 
803 public:
804 
807 
812 
814 
815 };
816 
817 template<class T>
820 {
821  return rcp(new NumberVisualDependency<T>(
824 }
825 
830 template<class DependeeType, class DependentType>
832 public:
833 
836 
845  RCP<const ParameterEntry> dependee,
846  RCP<ParameterEntry> dependent,
848 
857  RCP<const ParameterEntry> dependee,
858  ParameterEntryList dependents,
860 
862 
865 
874  {
875  return func_;
876  }
877 
879 
882 
884  virtual void evaluate();
885 
886 protected:
887 
889  virtual void validateDep() const;
890 
892 
895 
903  virtual void modifyArray(
904  DependeeType newAmount,
905  RCP<ParameterEntry> dependentToModify) = 0;
906 
914  virtual std::string getBadDependentValueErrorMessage() const=0;
915 
917 private:
918 
921 
926 
927  //}
928 };
929 
930 template<class DependeeType, class DependentType>
932  RCP<const ParameterEntry> dependee,
933  RCP<ParameterEntry> dependent,
935  Dependency(dependee, dependent),
936  func_(func)
937 {}
938 
939 template<class DependeeType, class DependentType>
941  RCP<const ParameterEntry> dependee,
942  ParameterEntryList dependents,
944  Dependency(dependee, dependents),
945  func_(func)
946 {}
947 
948 template<class DependeeType, class DependentType>
951  typeid(DependeeType) != getFirstDependee()->getAny().type(),
953  "Ay no! The dependee parameter types don't match." << std::endl <<
954  "Dependee Template Type: " << TypeNameTraits<DependeeType>::name() <<
955  std::endl <<
956  "Dependee Parameter Type: " << getFirstDependee()->getAny().typeName()
957  << std::endl << std::endl);
958 }
959 
960 template<class DependeeType, class DependentType>
962  DependeeType newAmount = Dependency::getFirstDependeeValue<DependeeType>();
963  if(!this->getFunctionObject().is_null()){
964  newAmount = this->getFunctionObject()->runFunction(newAmount);
965  }
966 
969  getBadDependentValueErrorMessage());
970 
971  for(
972  Dependency::ParameterEntryList::iterator it = this->getDependents().begin();
973  it != this->getDependents().end();
974  ++it)
975  {
976  modifyArray(newAmount, *it);
977  }
978 }
979 
980 
1003 template<class DependeeType, class DependentType>
1005  public ArrayModifierDependency<DependeeType, DependentType>
1006 {
1007 
1008 public:
1009 
1012 
1022  RCP<const ParameterEntry> dependee,
1023  RCP<ParameterEntry> dependent,
1025 
1035  RCP<const ParameterEntry> dependee,
1036  Dependency::ParameterEntryList dependents,
1038 
1040 
1043 
1045  std::string getTypeAttributeValue() const;
1046 
1048 
1049 protected:
1050 
1053 
1054  virtual void validateDep() const;
1055 
1057  void modifyArray(
1058  DependeeType newAmount, RCP<ParameterEntry> dependentToModify);
1059 
1061  std::string getBadDependentValueErrorMessage() const;
1062 
1064 
1065 };
1066 
1067 template<class DependeeType, class DependentType>
1069  RCP<const ParameterEntry> dependee,
1070  RCP<ParameterEntry> dependent,
1072  ArrayModifierDependency<DependeeType, DependentType>(dependee, dependent, func)
1073 {
1074  validateDep();
1075 }
1076 
1077 template<class DependeeType, class DependentType>
1079  RCP<const ParameterEntry> dependee,
1080  Dependency::ParameterEntryList dependents,
1082  ArrayModifierDependency<DependeeType, DependentType>(dependee, dependents, func)
1083 {
1084  validateDep();
1085 }
1086 
1087 
1088 template<class DependeeType, class DependentType>
1089 std::string
1091 const
1092 {
1093  return "NumberArrayLengthDependency(" +
1096 }
1097 
1098 template <class DependeeType, class DependentType>
1099 void
1101  DependeeType newAmount, RCP<ParameterEntry> dependentToModify)
1102 {
1103  const Array<DependentType> originalArray =
1104  any_cast<Array<DependentType> >(dependentToModify->getAny());
1105  Array<DependentType> newArray(newAmount);
1106  DependeeType i;
1107  for(
1109  i<originalArray.size() && i<newAmount;
1110  ++i)
1111  {
1112  newArray[i] = originalArray[i];
1113  }
1114 
1115  dependentToModify->setValue(newArray,
1116  false, dependentToModify->docString(), dependentToModify->validator());
1117 }
1118 
1119 template<class DependeeType, class DependentType>
1120 std::string
1122  std::ostringstream os;
1123  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;
1130  return os.str();
1131 }
1132 
1133 template<class DependeeType, class DependentType>
1134 void
1136  const
1137 {
1139  for(
1140  Dependency::ConstParameterEntryList::const_iterator it =
1141  this->getDependents().begin();
1142  it != this->getDependents().end();
1143  ++it)
1144  {
1146  typeid(Teuchos::Array<DependentType>) != (*it)->getAny().type(),
1148  "Ay no! The dependent parameter types don't match." << std::endl <<
1149  "Dependent Template Type: " <<
1150  TypeNameTraits<DependentType>::name() << std::endl <<
1151  "Dependent Parameter Type: " <<
1152  (*it)->getAny().typeName() << std::endl << std::endl);
1153  }
1154 }
1155 
1161 template<class DependeeType, class DependentType>
1162 class DummyObjectGetter<NumberArrayLengthDependency<DependeeType, DependentType> >{
1163 
1164 public:
1165 
1168 
1173  getDummyObject();
1174 
1176 
1177 };
1178 
1179 template<class DependeeType, class DependentType>
1182 {
1183  return rcp(
1187 }
1188 
1214 
1215 public:
1216 
1219 
1223  typedef std::map<std::string, RCP<const ParameterEntryValidator> >
1225 
1229  typedef std::pair<std::string, RCP<const ParameterEntryValidator> >
1231 
1233 
1236 
1251  RCP<const ParameterEntry> dependee,
1252  RCP<ParameterEntry> dependent,
1253  ValueToValidatorMap valuesAndValidators,
1254  RCP<ParameterEntryValidator> defaultValidator=null);
1255 
1270  RCP<const ParameterEntry> dependee,
1271  Dependency::ParameterEntryList dependents,
1272  ValueToValidatorMap valuesAndValidators,
1273  RCP<ParameterEntryValidator> defaultValidator = null);
1274 
1276 
1279 
1282  const ValueToValidatorMap& getValuesAndValidators() const;
1283 
1285  RCP<const ParameterEntryValidator> getDefaultValidator() const;
1286 
1288 
1291 
1293  void evaluate();
1294 
1296 
1299 
1301  std::string getTypeAttributeValue() const;
1302 
1304 
1305 protected:
1306 
1309 
1310  void validateDep() const;
1311 
1313 
1314 private:
1315 
1318 
1324 
1331 
1333 
1334 };
1335 
1336 
1342 template<>
1344 
1345 public:
1346 
1349 
1352  static RCP<StringValidatorDependency > getDummyObject();
1353 
1355 
1356 };
1357 
1374 
1375 public:
1376 
1379 
1391  RCP<const ParameterEntry> dependee,
1392  RCP<ParameterEntry> dependent,
1393  RCP<const ParameterEntryValidator> trueValidator,
1394  RCP<const ParameterEntryValidator> falseValidator=null);
1395 
1407  RCP<const ParameterEntry> dependee,
1408  Dependency::ParameterEntryList dependents,
1409  RCP<const ParameterEntryValidator> trueValidator,
1410  RCP<const ParameterEntryValidator> falseValidator=null);
1411 
1413 
1416 
1417  void evaluate();
1418 
1420 
1423 
1425  RCP<const ParameterEntryValidator> getTrueValidator() const;
1426 
1428  RCP<const ParameterEntryValidator> getFalseValidator() const;
1429 
1431 
1434 
1436  std::string getTypeAttributeValue() const;
1437 
1439 
1440 protected:
1441 
1444 
1445  void validateDep() const;
1446 
1448 
1449 private:
1450 
1453 
1459 
1461 
1462 };
1463 
1469 template<>
1471 
1472 public:
1473 
1476 
1478  static RCP<BoolValidatorDependency > getDummyObject();
1479 
1481 
1482 };
1483 
1513 template<class T>
1515 
1516 public:
1517 
1520 
1524  typedef std::pair<T,T> Range;
1525 
1529  typedef std::map<Range, RCP<const ParameterEntryValidator> >
1531 
1535  typedef std::pair<Range, RCP<const ParameterEntryValidator> >
1537 
1539 
1542 
1557  RCP<const ParameterEntry> dependee,
1558  RCP<ParameterEntry> dependent,
1559  RangeToValidatorMap rangesAndValidators,
1560  RCP<const ParameterEntryValidator> defaultValidator=null);
1561 
1576  RCP<const ParameterEntry> dependee,
1577  Dependency::ParameterEntryList dependents,
1578  RangeToValidatorMap rangesAndValidators,
1579  RCP<const ParameterEntryValidator> defaultValidator=null);
1580 
1582 
1585 
1588  return rangesAndValidators_;
1589  }
1590 
1593  return defaultValidator_;
1594  }
1595 
1597 
1600 
1602  void evaluate();
1603 
1605 
1608 
1610  std::string getTypeAttributeValue() const;
1611 
1613 
1614 protected:
1615 
1618 
1620  void validateDep() const;
1621 
1623 
1624 
1625 private:
1626 
1629 
1634 
1636 
1638 
1640 
1641 };
1642 
1643 template<class T>
1645  RCP<const ParameterEntry> dependee,
1646  RCP<ParameterEntry> dependent,
1647  RangeToValidatorMap rangesAndValidators,
1648  RCP<const ParameterEntryValidator> defaultValidator)
1649  :ValidatorDependency(dependee, dependent),
1650  rangesAndValidators_(rangesAndValidators),
1651  defaultValidator_(defaultValidator)
1652 {
1653  validateDep();
1654 }
1655 
1656 template<class T>
1658  RCP<const ParameterEntry> dependee,
1659  Dependency::ParameterEntryList dependents,
1660  RangeToValidatorMap rangesAndValidators,
1661  RCP<const ParameterEntryValidator> defaultValidator)
1662  :ValidatorDependency(dependee, dependents),
1663  rangesAndValidators_(rangesAndValidators),
1664  defaultValidator_(defaultValidator)
1665 {
1666  validateDep();
1667 }
1668 
1669 template<class T>
1671 {
1672  return "RangeValidatorDependency(" + TypeNameTraits<T>::name() + ")";
1673 }
1674 
1675 
1676 template<class T>
1678  typename RangeToValidatorMap::const_iterator it;
1679  T dependeeValue = getFirstDependeeValue<T>();
1680  for(
1681  it = rangesAndValidators_.begin();
1682  it != rangesAndValidators_.end();
1683  ++it)
1684  {
1685  T min = it->first.first;
1686  T max = it->first.second;
1687  if(dependeeValue >= min && dependeeValue <max){
1688  setDependentsToValidator(it->second);
1689  return;
1690  }
1691  }
1692  setDependentsToValidator(defaultValidator_);
1693 }
1694 
1695 template<class T>
1697  RCP<const ParameterEntry> dependee = getFirstDependee();
1698  TEUCHOS_TEST_FOR_EXCEPTION(dependee->getAny().type() != typeid(T),
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 <<
1703  "Templated Type: " << TypeNameTraits<T>::name() << std::endl << std::endl);
1704 
1706  rangesAndValidators_.size() < 1,
1708  "The rangesAndValidators map RangeValidatorDependency "
1709  "must have at least one entry!" << std::endl << std::endl);
1710 
1711  typename RangeToValidatorMap::const_iterator it =
1712  rangesAndValidators_.begin();
1713  RCP<const ParameterEntryValidator> firstValidator = it->second;
1714  // getting the raw pointer avoids a Clang warning about side effects in typeid
1715  const ParameterEntryValidator* rawValidatorPtr = firstValidator.get();
1716  ++it;
1717  for(; it!=rangesAndValidators_.end(); ++it){
1718  TEUCHOS_TEST_FOR_EXCEPTION( typeid(*rawValidatorPtr) != typeid(*(it->second)),
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!"
1727  );
1728  }
1729 
1731  nonnull(defaultValidator_)
1732  &&
1733  typeid(*rawValidatorPtr) != typeid(*defaultValidator_),
1735  "Ay no! The default validator of a RangeValidatorDependency "
1736  "must have the same type as the validators in rangesAndValidators map."
1737  );
1738 
1739 }
1740 
1741 template<class T>
1744 {
1745  typename ParameterEntryList::const_iterator it;
1746  for(
1747  it = getDependents().begin();
1748  it != getDependents().end();
1749  ++it)
1750  {
1751  (*it)->setValidator(toSet);
1752  }
1753 }
1754 
1760 template<class T>
1762 
1763 public:
1764 
1767 
1772 
1774 
1775 };
1776 
1777 template<class T>
1780 {
1782  typename RangeValidatorDependency<T>::Range dummyRange(
1784  RCP<FileNameValidator> dummyValidator =
1786  dummyMap.insert(typename RangeValidatorDependency<T>::RangeValidatorPair(
1787  dummyRange, dummyValidator));
1788  return rcp(new RangeValidatorDependency<T>(
1791  dummyMap));
1792 }
1793 
1798 template<class DependeeType, class DependentType>
1800  public ArrayModifierDependency<DependeeType, DependentType>
1801 {
1802 
1803 public:
1804 
1807 
1817  RCP<const ParameterEntry> dependee,
1818  RCP<ParameterEntry> dependent,
1820  ArrayModifierDependency<DependeeType, DependentType>(
1821  dependee,
1822  dependent,
1823  func)
1824  {}
1825 
1826 
1836  RCP<const ParameterEntry> dependee,
1837  Dependency::ParameterEntryList dependents,
1839  ArrayModifierDependency<DependeeType, DependentType>(
1840  dependee,
1841  dependents,
1842  func)
1843  {}
1844 
1846 
1847 protected:
1848 
1851 
1852  virtual void validateDep() const;
1853 
1855 
1856 };
1857 
1858 template<class DependeeType, class DependentType>
1859 void
1861  const
1862 {
1864  for(
1865  Dependency::ConstParameterEntryList::const_iterator it =
1866  this->getDependents().begin();
1867  it != this->getDependents().end();
1868  ++it)
1869  {
1871  typeid(Teuchos::TwoDArray<DependentType>) != (*it)->getAny().type(),
1873  "Ay no! The dependent parameter types don't match." << std::endl <<
1874  "Dependent Template Type: " <<
1875  TypeNameTraits<DependentType>::name() << std::endl <<
1876  "Dependent Parameter Type: " <<
1877  (*it)->getAny().typeName() << std::endl << std::endl);
1878  }
1879 }
1880 
1881 
1889 template<class DependeeType, class DependentType>
1891  public TwoDArrayModifierDependency<DependeeType, DependentType>
1892 {
1893 
1894 public:
1895 
1898 
1908  RCP<const ParameterEntry> dependee,
1909  RCP<ParameterEntry> dependent,
1911 
1912 
1922  RCP<const ParameterEntry> dependee,
1923  Dependency::ParameterEntryList dependents,
1925 
1927 
1930 
1932  std::string getTypeAttributeValue() const;
1933 
1935 
1936 protected:
1937 
1940 
1942  void modifyArray(
1943  DependeeType newAmount, RCP<ParameterEntry> dependentToModify);
1944 
1946  std::string getBadDependentValueErrorMessage() const;
1948 
1949 };
1950 
1951 template<class DependeeType, class DependentType>
1953  RCP<const ParameterEntry> dependee,
1954  RCP<ParameterEntry> dependent,
1956  TwoDArrayModifierDependency<DependeeType, DependentType>(
1957  dependee, dependent, func)
1958 {
1959  this->validateDep();
1960 }
1961 
1962 template<class DependeeType, class DependentType>
1964  RCP<const ParameterEntry> dependee,
1965  Dependency::ParameterEntryList dependents,
1967  TwoDArrayModifierDependency<DependeeType, DependentType>(
1968  dependee, dependents, func)
1969 {
1970  this->validateDep();
1971 }
1972 
1973 
1974 template<class DependeeType, class DependentType>
1975 std::string
1977 const
1978 {
1979  return "TwoDRowDependency(" +
1982 }
1983 
1984 template <class DependeeType, class DependentType>
1985 void
1987  DependeeType newAmount,
1988  RCP<ParameterEntry> dependentToModify)
1989 {
1990  TwoDArray<DependentType> originalArray =
1991  any_cast<TwoDArray<DependentType> >(dependentToModify->getAny());
1992  originalArray.resizeRows(newAmount);
1993  dependentToModify->setValue(originalArray,
1994  false, dependentToModify->docString(), dependentToModify->validator());
1995 }
1996 
1997 template<class DependeeType, class DependentType>
1998 std::string
2000  std::ostringstream os;
2001  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;
2008  return os.str();
2009 }
2010 
2016 template<class DependeeType, class DependentType>
2017 class DummyObjectGetter<TwoDRowDependency<DependeeType, DependentType> >{
2018 
2019 public:
2020 
2023 
2028  getDummyObject();
2029 
2031 
2032 };
2033 
2034 template<class DependeeType, class DependentType>
2037 {
2038  return rcp(
2042 }
2043 
2044 
2052 template<class DependeeType, class DependentType>
2054  public TwoDArrayModifierDependency<DependeeType, DependentType>
2055 {
2056 
2057 public:
2058 
2061 
2071  RCP<const ParameterEntry> dependee,
2072  RCP<ParameterEntry> dependent,
2074 
2075 
2085  RCP<const ParameterEntry> dependee,
2086  Dependency::ParameterEntryList dependents,
2088 
2090 
2093 
2095  std::string getTypeAttributeValue() const;
2096 
2098 
2099 protected:
2100 
2103 
2105  void modifyArray(
2106  DependeeType newAmount, RCP<ParameterEntry> dependentToModify);
2107 
2109  std::string getBadDependentValueErrorMessage() const;
2111 
2112 };
2113 
2114 template<class DependeeType, class DependentType>
2116  RCP<const ParameterEntry> dependee,
2117  RCP<ParameterEntry> dependent,
2119  TwoDArrayModifierDependency<DependeeType, DependentType>(
2120  dependee, dependent, func)
2121 {
2122  this->validateDep();
2123 }
2124 
2125 template<class DependeeType, class DependentType>
2127  RCP<const ParameterEntry> dependee,
2128  Dependency::ParameterEntryList dependents,
2130  TwoDArrayModifierDependency<DependeeType, DependentType>(
2131  dependee, dependents, func)
2132 {
2133  this->validateDep();
2134 }
2135 
2136 
2137 template<class DependeeType, class DependentType>
2138 std::string
2140 const
2141 {
2142  return "TwoDColDependency(" +
2145 }
2146 
2147 template <class DependeeType, class DependentType>
2148 void
2150  DependeeType newAmount,
2151  RCP<ParameterEntry> dependentToModify)
2152 {
2153  TwoDArray<DependentType> originalArray =
2154  any_cast<TwoDArray<DependentType> >(dependentToModify->getAny());
2155  originalArray.resizeCols(newAmount);
2156  dependentToModify->setValue(originalArray,
2157  false, dependentToModify->docString(), dependentToModify->validator());
2158 }
2159 
2160 template<class DependeeType, class DependentType>
2161 std::string
2163  std::ostringstream os;
2164  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;
2171  return os.str();
2172 }
2173 
2179 template<class DependeeType, class DependentType>
2180 class DummyObjectGetter<TwoDColDependency<DependeeType, DependentType> >{
2181 
2182 public:
2183 
2186 
2191  getDummyObject();
2192 
2194 
2195 };
2196 
2197 template<class DependeeType, class DependentType>
2200 {
2201  return rcp(
2205 }
2206 
2207 
2208 
2209 } //namespace Teuchos
2210 #endif //TEUCHOS_STANDARDDEPENDCIES_HPP_
RCP< const ParameterEntryValidator > getDefaultValidator() const
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...
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 dependency 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...
RCP< const ParameterEntryValidator > validator() const
Return the (optional) validator object.
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 &quot;value&quot; 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.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
bool isType() const
Test the type of the data being contained.
std::string getBadDependentValueErrorMessage() const
T * get() const
Get the raw C++ pointer to the underlying object.
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.
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.
const RangeToValidatorMap & getRangeToValidatorMap() const
A thin wrapper around the Array class which causes it to be interpreted as a 2D Array.
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...
TwoDArrayModifierDependency(RCP< const ParameterEntry > dependee, RCP< ParameterEntry > dependent, RCP< const SimpleFunctionObject< DependeeType > > func=null)
Constructs a TwoDArrayModifierDependency.
std::string getBadDependentValueErrorMessage() 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)
TwoDColDependency(RCP< const ParameterEntry > dependee, RCP< ParameterEntry > dependent, RCP< const SimpleFunctionObject< DependeeType > > func=null)
Constructs a TwoDColDependency.
#define TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT
Abstract interface for an object that can validate a ParameterEntry&#39;s value.
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.
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...
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...
size_type size() const
Defines basic traits for the scalar field type.
static T zero()
Returns representation of zero for this scalar type.
An abstract base class for all validator dependencies.
std::string typeName() const
Return the name of the type.
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.
const std::type_info & type() const
Return the type of value being stored.
void modifyArray(DependeeType newAmount, RCP< ParameterEntry > dependentToModify)
std::string docString() const
Return the (optional) documentation std::string.
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.
RCP< const SimpleFunctionObject< DependeeType > > getFunctionObject() const
Retrieves the function being used to calculate the amount by which an arrays dimensional attribute sh...
A number visual dependency says the following about the relationship between two elements in a Parame...
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.
RCP< const SimpleFunctionObject< T > > getFunctionObject() const
Const version of function getter.