Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos_StandardDependencies.hpp
Go to the documentation of this file.
1// @HEADER
2// ***********************************************************************
3//
4// Teuchos: Common Tools Package
5// Copyright (2004) Sandia Corporation
6//
7// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8// license for use of this work by or on behalf of the U.S. Government.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38//
39// ***********************************************************************
40// @HEADER
41
42
43
44#ifndef TEUCHOS_STANDARDDEPENDCIES_HPP_
45#define TEUCHOS_STANDARDDEPENDCIES_HPP_
46
50
51#include "Teuchos_Dependency.hpp"
52#include "Teuchos_StandardParameterEntryValidators.hpp"
54#include "Teuchos_StandardFunctionObjects.hpp"
57
58
59namespace Teuchos{
60
61
72class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT VisualDependency : public Dependency{
73
74public:
75
77 static const bool& getShowIfDefaultValue(){
78 static const bool SHOW_IF_DEFAULT_VALUE = true;
79 return SHOW_IF_DEFAULT_VALUE;
80 }
81
82
85
96 RCP<ParameterEntry> dependent,
97 bool showIf=getShowIfDefaultValue());
98
109 ParameterEntryList dependents,
110 bool showIf=getShowIfDefaultValue());
111
121 ConstParameterEntryList dependees,
122 RCP<ParameterEntry> dependent,
123 bool showIf=getShowIfDefaultValue());
124
134 ConstParameterEntryList dependees,
135 ParameterEntryList dependents,
136 bool showIf=getShowIfDefaultValue());
137
139
141
142
149 virtual bool getDependeeState() const = 0;
150
154 bool isDependentVisible() const;
155
157 bool getShowIf() const;
158
160
163
165 void evaluate();
166
168
169private:
170
173
177 bool dependentVisible_;
178
183 bool showIf_;
184
186
187};
188
192class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT ValidatorDependency : public Dependency{
193
194public:
195
198
207 RCP<ParameterEntry> dependent);
208
217 ParameterEntryList dependents);
218
220
223
225 virtual void evaluate() = 0;
226
228
229};
230
244class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT StringVisualDependency : public VisualDependency{
245
246public:
247
250
255
257
260
276 RCP<ParameterEntry> dependent,
277 std::string value,
278 bool showIf=true);
279
295 RCP<ParameterEntry> dependent,
296 const ValueList& values,
297 bool showIf=true);
298
315 const std::string& value,
316 bool showIf=true);
317
335 const ValueList& values,
336 bool showIf=true);
337
339
342
344 const ValueList& getValues() const;
345
347
350
352 bool getDependeeState() const;
353
355
358
360 std::string getTypeAttributeValue() const;
361
363
364protected:
365
368
370 void validateDep() const;
371
373
374private:
375
378
382 const ValueList values_;
383
385
386};
387
388
394template<>
395class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT DummyObjectGetter<StringVisualDependency>{
396
397public:
398
401
406
408
409};
410
411
425class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT BoolVisualDependency : public VisualDependency{
426
427public:
428
431
443 RCP<ParameterEntry> dependent,
444 bool showIf=true);
445
458 bool showIf=true);
459
461
464
466 bool getDependeeState() const;
467
469
472
474 std::string getTypeAttributeValue() const;
475
477
478protected:
479
482
484 void validateDep() const;
485
487
488};
489
490
496template<>
497class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT DummyObjectGetter<BoolVisualDependency>{
498
499public:
500
503
508
510
511};
512
529class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT ConditionVisualDependency : public VisualDependency{
530
531public:
532
535
548 RCP<const Condition> condition,
549 RCP<ParameterEntry> dependent,
550 bool showIf=true);
551
563 RCP<const Condition> condition,
565 bool showIf=true);
566
568
571
574
577
579 bool getDependeeState() const;
580
582
585
587 std::string getTypeAttributeValue() const;
588
590
591protected:
592
595
597 void validateDep() const {}
598
600
601
602private:
603
606
610 RCP<const Condition> condition_;
611
613
614};
615
616
622template<>
623class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT DummyObjectGetter<ConditionVisualDependency>{
624
625public:
626
629
633
635
636};
637
638
659template <class T>
661
662public:
663
666
689 RCP<ParameterEntry> dependent,
690 bool showIf=true,
691 RCP<SimpleFunctionObject<T> > func=null);
692
715 ParameterEntryList dependents,
716 bool showIf=true,
717 RCP<SimpleFunctionObject<T> > func=null);
718
720
723
724 bool getDependeeState() const;
725
727
730
732 std::string getTypeAttributeValue() const;
733
735
738
741
743
744protected:
745
748
750 void validateDep() const;
751
753
754private:
755
758
764
766 //
767};
768
769template<class T>
772 RCP<ParameterEntry> dependent,
773 bool showIf,
775 :VisualDependency(dependee, dependent, showIf),
776 func_(func)
777{
778 validateDep();
779}
780
781template<class T>
784 ParameterEntryList dependents,
785 bool showIf,
787 :VisualDependency(dependee, dependents, showIf),
788 func_(func)
789{
790 validateDep();
791}
792
793template<class T>
795 T value = getFirstDependeeValue<T>();
796 if(!func_.is_null()){
797 value = func_->runFunction(value);
798 }
799 return value > ScalarTraits<T>::zero() ? true : false;
800}
801
802template<class T>
804 return "NumberVisualDependency(" + TypeNameTraits<T>::name() + ")";
805}
806
807template<class T>
810{
811 return func_.getConst();
812}
813
814template<class T>
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 <<
824 "Template Type: " << TypeNameTraits<T>::name() << std::endl <<
825 std::endl);
826}
827
828
834template<class T>
836
837public:
838
841
846
848
849};
850
851template<class T>
859
864template<class DependeeType, class DependentType>
866public:
867
870
880 RCP<ParameterEntry> dependent,
881 RCP<const SimpleFunctionObject<DependeeType> > func=null);
882
892 ParameterEntryList dependents,
893 RCP<const SimpleFunctionObject<DependeeType> > func=null);
894
896
899
908 {
909 return func_;
910 }
911
913
916
918 virtual void evaluate();
919
920protected:
921
923 virtual void validateDep() const;
924
926
929
937 virtual void modifyArray(
938 DependeeType newAmount,
939 RCP<ParameterEntry> dependentToModify) = 0;
940
948 virtual std::string getBadDependentValueErrorMessage() const=0;
949
951private:
952
955
960
961 //}
962};
963
964template<class DependeeType, class DependentType>
972
973template<class DependeeType, class DependentType>
981
982template<class DependeeType, class DependentType>
985 typeid(DependeeType) != getFirstDependee()->getAny().type(),
987 "Ay no! The dependee parameter types don't match." << std::endl <<
988 "Dependee Template Type: " << TypeNameTraits<DependeeType>::name() <<
989 std::endl <<
990 "Dependee Parameter Type: " << getFirstDependee()->getAny().typeName()
991 << std::endl << std::endl);
992}
993
994template<class DependeeType, class DependentType>
996 DependeeType newAmount = Dependency::getFirstDependeeValue<DependeeType>();
997 if(!this->getFunctionObject().is_null()){
998 newAmount = this->getFunctionObject()->runFunction(newAmount);
999 }
1000
1004
1005 for(
1006 Dependency::ParameterEntryList::iterator it = this->getDependents().begin();
1007 it != this->getDependents().end();
1008 ++it)
1009 {
1010 modifyArray(newAmount, *it);
1011 }
1012}
1013
1014
1037template<class DependeeType, class DependentType>
1039 public ArrayModifierDependency<DependeeType, DependentType>
1040{
1041
1042public:
1043
1046
1057 RCP<ParameterEntry> dependent,
1058 RCP<const SimpleFunctionObject<DependeeType> > func=null);
1059
1071 RCP<const SimpleFunctionObject<DependeeType> > func=null);
1072
1074
1077
1079 std::string getTypeAttributeValue() const;
1080
1082
1083protected:
1084
1087
1088 virtual void validateDep() const;
1089
1091 void modifyArray(
1092 DependeeType newAmount, RCP<ParameterEntry> dependentToModify);
1093
1095 std::string getBadDependentValueErrorMessage() const;
1096
1098
1099};
1100
1101template<class DependeeType, class DependentType>
1104 RCP<ParameterEntry> dependent,
1106 ArrayModifierDependency<DependeeType, DependentType>(dependee, dependent, func)
1107{
1108 validateDep();
1109}
1110
1111template<class DependeeType, class DependentType>
1120
1121
1122template<class DependeeType, class DependentType>
1123std::string
1131
1132template <class DependeeType, class DependentType>
1133void
1135 DependeeType newAmount, RCP<ParameterEntry> dependentToModify)
1136{
1137 const Array<DependentType> originalArray =
1138 any_cast<Array<DependentType> >(dependentToModify->getAny());
1139 Array<DependentType> newArray(newAmount);
1140 DependeeType i;
1141 for(
1143 i<originalArray.size() && i<newAmount;
1144 ++i)
1145 {
1146 newArray[i] = originalArray[i];
1147 }
1148
1149 dependentToModify->setValue(newArray,
1150 false, dependentToModify->docString(), dependentToModify->validator());
1151}
1152
1153template<class DependeeType, class DependentType>
1154std::string
1156 std::ostringstream os;
1157 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;
1164 return os.str();
1165}
1166
1167template<class DependeeType, class DependentType>
1168void
1170 const
1171{
1173 for(
1174 Dependency::ConstParameterEntryList::const_iterator it =
1175 this->getDependents().begin();
1176 it != this->getDependents().end();
1177 ++it)
1178 {
1180 typeid(Teuchos::Array<DependentType>) != (*it)->getAny().type(),
1182 "Ay no! The dependent parameter types don't match." << std::endl <<
1183 "Dependent Template Type: " <<
1184 TypeNameTraits<DependentType>::name() << std::endl <<
1185 "Dependent Parameter Type: " <<
1186 (*it)->getAny().typeName() << std::endl << std::endl);
1187 }
1188}
1189
1195template<class DependeeType, class DependentType>
1196class DummyObjectGetter<NumberArrayLengthDependency<DependeeType, DependentType> >{
1197
1198public:
1199
1202
1208
1210
1211};
1212
1213template<class DependeeType, class DependentType>
1222
1247class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT StringValidatorDependency : public ValidatorDependency{
1248
1249public:
1250
1253
1257 typedef std::map<std::string, RCP<const ParameterEntryValidator> >
1259
1263 typedef std::pair<std::string, RCP<const ParameterEntryValidator> >
1265
1267
1270
1286 RCP<ParameterEntry> dependent,
1287 ValueToValidatorMap valuesAndValidators,
1288 RCP<ParameterEntryValidator> defaultValidator=null);
1289
1306 ValueToValidatorMap valuesAndValidators,
1307 RCP<ParameterEntryValidator> defaultValidator = null);
1308
1310
1313
1317
1320
1322
1325
1327 void evaluate();
1328
1330
1333
1335 std::string getTypeAttributeValue() const;
1336
1338
1339protected:
1340
1343
1344 void validateDep() const;
1345
1347
1348private:
1349
1352
1357 ValueToValidatorMap valuesAndValidators_;
1358
1364 RCP<ParameterEntryValidator> defaultValidator_;
1365
1367
1368};
1369
1370
1376template<>
1377class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT DummyObjectGetter<StringValidatorDependency>{
1378
1379public:
1380
1383
1387
1389
1390};
1391
1407class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT BoolValidatorDependency : public ValidatorDependency{
1408
1409public:
1410
1413
1426 RCP<ParameterEntry> dependent,
1428 RCP<const ParameterEntryValidator> falseValidator=null);
1429
1444 RCP<const ParameterEntryValidator> falseValidator=null);
1445
1447
1450
1451 void evaluate();
1452
1454
1457
1460
1463
1465
1468
1470 std::string getTypeAttributeValue() const;
1471
1473
1474protected:
1475
1478
1479 void validateDep() const;
1480
1482
1483private:
1484
1487
1492 RCP<const ParameterEntryValidator> trueValidator_, falseValidator_;
1493
1495
1496};
1497
1503template<>
1504class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT DummyObjectGetter<BoolValidatorDependency>{
1505
1506public:
1507
1510
1513
1515
1516};
1517
1547template<class T>
1549
1550public:
1551
1554
1558 typedef std::pair<T,T> Range;
1559
1563 typedef std::map<Range, RCP<const ParameterEntryValidator> >
1565
1569 typedef std::pair<Range, RCP<const ParameterEntryValidator> >
1571
1573
1576
1592 RCP<ParameterEntry> dependent,
1593 RangeToValidatorMap rangesAndValidators,
1594 RCP<const ParameterEntryValidator> defaultValidator=null);
1595
1612 RangeToValidatorMap rangesAndValidators,
1613 RCP<const ParameterEntryValidator> defaultValidator=null);
1614
1616
1619
1622 return rangesAndValidators_;
1623 }
1624
1627 return defaultValidator_;
1628 }
1629
1631
1634
1636 void evaluate();
1637
1639
1642
1644 std::string getTypeAttributeValue() const;
1645
1647
1648protected:
1649
1652
1654 void validateDep() const;
1655
1657
1658
1659private:
1660
1663
1667 RangeToValidatorMap rangesAndValidators_;
1668
1669 void setDependentsToValidator(RCP<const ParameterEntryValidator> toSet);
1670
1671 RCP<const ParameterEntryValidator> defaultValidator_;
1672
1674
1675};
1676
1677template<class T>
1680 RCP<ParameterEntry> dependent,
1681 RangeToValidatorMap rangesAndValidators,
1682 RCP<const ParameterEntryValidator> defaultValidator)
1683 :ValidatorDependency(dependee, dependent),
1684 rangesAndValidators_(rangesAndValidators),
1685 defaultValidator_(defaultValidator)
1686{
1687 validateDep();
1688}
1689
1690template<class T>
1694 RangeToValidatorMap rangesAndValidators,
1695 RCP<const ParameterEntryValidator> defaultValidator)
1696 :ValidatorDependency(dependee, dependents),
1697 rangesAndValidators_(rangesAndValidators),
1698 defaultValidator_(defaultValidator)
1699{
1700 validateDep();
1701}
1702
1703template<class T>
1705{
1706 return "RangeValidatorDependency(" + TypeNameTraits<T>::name() + ")";
1707}
1708
1709
1710template<class T>
1712 typename RangeToValidatorMap::const_iterator it;
1713 T dependeeValue = getFirstDependeeValue<T>();
1714 for(
1715 it = rangesAndValidators_.begin();
1716 it != rangesAndValidators_.end();
1717 ++it)
1718 {
1719 T min = it->first.first;
1720 T max = it->first.second;
1721 if(dependeeValue >= min && dependeeValue <max){
1722 setDependentsToValidator(it->second);
1723 return;
1724 }
1725 }
1726 setDependentsToValidator(defaultValidator_);
1727}
1728
1729template<class T>
1732 TEUCHOS_TEST_FOR_EXCEPTION(dependee->getAny().type() != typeid(T),
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 <<
1737 "Templated Type: " << TypeNameTraits<T>::name() << std::endl << std::endl);
1738
1740 rangesAndValidators_.size() < 1,
1742 "The rangesAndValidators map RangeValidatorDependency "
1743 "must have at least one entry!" << std::endl << std::endl);
1744
1745 typename RangeToValidatorMap::const_iterator it =
1746 rangesAndValidators_.begin();
1747 RCP<const ParameterEntryValidator> firstValidator = it->second;
1748 // getting the raw pointer avoids a Clang warning about side effects in typeid
1749 const ParameterEntryValidator* rawValidatorPtr = firstValidator.get();
1750 ++it;
1751 for(; it!=rangesAndValidators_.end(); ++it){
1752 TEUCHOS_TEST_FOR_EXCEPTION( typeid(*rawValidatorPtr) != typeid(*(it->second)),
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!"
1761 );
1762 }
1763
1765 nonnull(defaultValidator_)
1766 &&
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."
1771 );
1772
1773}
1774
1775template<class T>
1776void RangeValidatorDependency<T>::setDependentsToValidator(
1778{
1779 typename ParameterEntryList::const_iterator it;
1780 for(
1781 it = getDependents().begin();
1782 it != getDependents().end();
1783 ++it)
1784 {
1785 (*it)->setValidator(toSet);
1786 }
1787}
1788
1794template<class T>
1796
1797public:
1798
1801
1806
1808
1809};
1810
1811template<class T>
1827
1832template<class DependeeType, class DependentType>
1834 public ArrayModifierDependency<DependeeType, DependentType>
1835{
1836
1837public:
1838
1841
1852 RCP<ParameterEntry> dependent,
1853 RCP<const SimpleFunctionObject<DependeeType> > func=null):
1854 ArrayModifierDependency<DependeeType, DependentType>(
1855 dependee,
1856 dependent,
1857 func)
1858 {}
1859
1860
1872 RCP<const SimpleFunctionObject<DependeeType> > func=null):
1873 ArrayModifierDependency<DependeeType, DependentType>(
1874 dependee,
1875 dependents,
1876 func)
1877 {}
1878
1880
1881protected:
1882
1885
1886 virtual void validateDep() const;
1887
1889
1890};
1891
1892template<class DependeeType, class DependentType>
1893void
1895 const
1896{
1898 for(
1899 Dependency::ConstParameterEntryList::const_iterator it =
1900 this->getDependents().begin();
1901 it != this->getDependents().end();
1902 ++it)
1903 {
1905 typeid(Teuchos::TwoDArray<DependentType>) != (*it)->getAny().type(),
1907 "Ay no! The dependent parameter types don't match." << std::endl <<
1908 "Dependent Template Type: " <<
1909 TypeNameTraits<DependentType>::name() << std::endl <<
1910 "Dependent Parameter Type: " <<
1911 (*it)->getAny().typeName() << std::endl << std::endl);
1912 }
1913}
1914
1915
1923template<class DependeeType, class DependentType>
1925 public TwoDArrayModifierDependency<DependeeType, DependentType>
1926{
1927
1928public:
1929
1932
1943 RCP<ParameterEntry> dependent,
1944 RCP<const SimpleFunctionObject<DependeeType> > func=null);
1945
1946
1958 RCP<const SimpleFunctionObject<DependeeType> > func=null);
1959
1961
1964
1966 std::string getTypeAttributeValue() const;
1967
1969
1970protected:
1971
1974
1976 void modifyArray(
1977 DependeeType newAmount, RCP<ParameterEntry> dependentToModify);
1978
1980 std::string getBadDependentValueErrorMessage() const;
1982
1983};
1984
1985template<class DependeeType, class DependentType>
1988 RCP<ParameterEntry> dependent,
1990 TwoDArrayModifierDependency<DependeeType, DependentType>(
1991 dependee, dependent, func)
1992{
1993 this->validateDep();
1994}
1995
1996template<class DependeeType, class DependentType>
2001 TwoDArrayModifierDependency<DependeeType, DependentType>(
2002 dependee, dependents, func)
2003{
2004 this->validateDep();
2005}
2006
2007
2008template<class DependeeType, class DependentType>
2009std::string
2017
2018template <class DependeeType, class DependentType>
2019void
2021 DependeeType newAmount,
2022 RCP<ParameterEntry> dependentToModify)
2023{
2024 TwoDArray<DependentType> originalArray =
2025 any_cast<TwoDArray<DependentType> >(dependentToModify->getAny());
2026 originalArray.resizeRows(newAmount);
2027 dependentToModify->setValue(originalArray,
2028 false, dependentToModify->docString(), dependentToModify->validator());
2029}
2030
2031template<class DependeeType, class DependentType>
2032std::string
2034 std::ostringstream os;
2035 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;
2042 return os.str();
2043}
2044
2050template<class DependeeType, class DependentType>
2051class DummyObjectGetter<TwoDRowDependency<DependeeType, DependentType> >{
2052
2053public:
2054
2057
2063
2065
2066};
2067
2068template<class DependeeType, class DependentType>
2077
2078
2086template<class DependeeType, class DependentType>
2088 public TwoDArrayModifierDependency<DependeeType, DependentType>
2089{
2090
2091public:
2092
2095
2106 RCP<ParameterEntry> dependent,
2107 RCP<const SimpleFunctionObject<DependeeType> > func=null);
2108
2109
2121 RCP<const SimpleFunctionObject<DependeeType> > func=null);
2122
2124
2127
2129 std::string getTypeAttributeValue() const;
2130
2132
2133protected:
2134
2137
2139 void modifyArray(
2140 DependeeType newAmount, RCP<ParameterEntry> dependentToModify);
2141
2143 std::string getBadDependentValueErrorMessage() const;
2145
2146};
2147
2148template<class DependeeType, class DependentType>
2151 RCP<ParameterEntry> dependent,
2153 TwoDArrayModifierDependency<DependeeType, DependentType>(
2154 dependee, dependent, func)
2155{
2156 this->validateDep();
2157}
2158
2159template<class DependeeType, class DependentType>
2164 TwoDArrayModifierDependency<DependeeType, DependentType>(
2165 dependee, dependents, func)
2166{
2167 this->validateDep();
2168}
2169
2170
2171template<class DependeeType, class DependentType>
2172std::string
2180
2181template <class DependeeType, class DependentType>
2182void
2184 DependeeType newAmount,
2185 RCP<ParameterEntry> dependentToModify)
2186{
2187 TwoDArray<DependentType> originalArray =
2188 any_cast<TwoDArray<DependentType> >(dependentToModify->getAny());
2189 originalArray.resizeCols(newAmount);
2190 dependentToModify->setValue(originalArray,
2191 false, dependentToModify->docString(), dependentToModify->validator());
2192}
2193
2194template<class DependeeType, class DependentType>
2195std::string
2197 std::ostringstream os;
2198 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;
2205 return os.str();
2206}
2207
2213template<class DependeeType, class DependentType>
2214class DummyObjectGetter<TwoDColDependency<DependeeType, DependentType> >{
2215
2216public:
2217
2220
2226
2228
2229};
2230
2231template<class DependeeType, class DependentType>
2240
2241
2242
2243} //namespace Teuchos
2244#endif //TEUCHOS_STANDARDDEPENDCIES_HPP_
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,...
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.
size_type size() const
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.
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...
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...
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...
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.
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::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,...
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...
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.
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.
void modifyArray(DependeeType newAmount, RCP< ParameterEntry > dependentToModify)
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)
TwoDRowDependency(RCP< const ParameterEntry > dependee, RCP< ParameterEntry > dependent, RCP< const SimpleFunctionObject< DependeeType > > func=null)
Constructs a TwoDRowDependency.
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.