Teuchos - Trilinos Tools Package  Version of the Day
Teuchos_ParameterList.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 #ifndef TEUCHOS_PARAMETER_LIST_H
44 #define TEUCHOS_PARAMETER_LIST_H
45 
50 #include "Teuchos_ParameterListExceptions.hpp"
52 #include "Teuchos_StringIndexedOrderedValueObjectContainer.hpp"
53 #include "Teuchos_Assert.hpp"
54 #include "Teuchos_RCP.hpp"
55 #include "Teuchos_Array.hpp"
56 #include "Teuchos_map.hpp"
57 
58 
63 namespace Teuchos {
64 
75 };
76 
87 };
88 
132 class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT ParameterList {
133 
136 
139 
140 public:
141 
143 
144 
147 
149  class PrintOptions {
150  public:
151  PrintOptions() : indent_(0), showTypes_(false), showFlags_(false), showDoc_(false) {}
152  PrintOptions& indent(int _indent) { indent_ = _indent; return *this; }
153  PrintOptions& showTypes(bool _showTypes) { showTypes_ = _showTypes; return *this; }
154  PrintOptions& showFlags(bool _showFlags) { showFlags_ = _showFlags; return *this; }
155  PrintOptions& showDoc(bool _showDoc) { showDoc_ = _showDoc; return *this; }
156  PrintOptions& incrIndent(int indents) { indent_ += indents; return *this; }
157  int indent() const { return indent_; }
158  bool showTypes() const { return showTypes_; }
159  bool showFlags() const { return showFlags_; }
160  bool showDoc() const { return showDoc_; }
161  PrintOptions copy() const { return PrintOptions(*this); }
162  private:
163  int indent_;
164  bool showTypes_;
165  bool showFlags_;
166  bool showDoc_;
167  };
168 
170 
172 
173 
175  ParameterList();
176 
178  ParameterList(const std::string &name);
179 
181  ParameterList(const ParameterList& source);
182 
184  virtual ~ParameterList();
185 
187  Ordinal numParams () const;
188 
190 
192 
194  ParameterList& setName( const std::string &name );
195 
199  ParameterList& operator= (const ParameterList& source);
200 
209  ParameterList& setParameters(const ParameterList& source);
210 
220  ParameterList& setParametersNotAlreadySet(const ParameterList& source);
221 
229  ParameterList& disableRecursiveValidation();
230 
249  template<typename T>
250  ParameterList& set (std::string const& name,
251  T const& value,
252  std::string const& docString = "",
253  RCP<const ParameterEntryValidator> const& validator = null);
254 
259  ParameterList& set(
260  std::string const& name, char value[], std::string const& docString = "",
261  RCP<const ParameterEntryValidator> const& validator = null
262  );
263 
268  ParameterList& set(
269  std::string const& name, const char value[], std::string const& docString = "",
270  RCP<const ParameterEntryValidator> const& validator = null
271  );
272 
276  ParameterList& set(
277  std::string const& name, ParameterList const& value, std::string const& docString = ""
278  );
279 
284  ParameterList& setEntry(const std::string& name, const ParameterEntry& entry);
285 
287 
289 
306  template<typename T>
307  T& get(const std::string& name, T def_value);
308 
312  std::string& get(const std::string& name, char def_value[]);
313 
317  std::string& get(const std::string& name, const char def_value[]);
318 
349  template<typename T>
350  T& get (const std::string& name);
351 
379  template<typename T>
380  const T& get (const std::string& name) const;
381 
387  template<typename T>
388  inline
389  T* getPtr(const std::string& name);
390 
396  template<typename T>
397  inline
398  const T* getPtr(const std::string& name) const;
399 
400  // ToDo: Add getSafePtr() functions to return Ptr<T> instead of raw T*
401 
407  ParameterEntry& getEntry(const std::string& name);
408 
414  inline
415  const ParameterEntry& getEntry(const std::string& name) const;
416 
419  inline
420  ParameterEntry* getEntryPtr(const std::string& name);
421 
422  // ToDo: Add function called getEntrySafePtr() to return Ptr<> as the main
423  // implementation and deprecate getEntryPtr()
424 
427  inline
428  const ParameterEntry* getEntryPtr(const std::string& name) const;
429 
432  inline RCP<ParameterEntry> getEntryRCP(const std::string& name);
433 
436  inline RCP<const ParameterEntry> getEntryRCP(const std::string& name) const;
437 
439 
441 
442 
456  bool remove(
457  std::string const& name, bool throwIfNotExists = true
458  );
459 
461 
463 
464 
470  ParameterList& sublist(
471  const std::string& name, bool mustAlreadyExist = false
472  ,const std::string& docString = ""
473  );
474 
479  const ParameterList& sublist(const std::string& name) const;
480 
482 
484 
485 
487  const std::string& name() const;
488 
493  bool isParameter (const std::string& name) const;
494 
499  bool isSublist (const std::string& name) const;
500 
506  template<typename T>
507  bool isType (const std::string& name) const;
508 
509 #ifndef DOXYGEN_SHOULD_SKIP_THIS
510 
520  template<typename T>
521  bool isType(const std::string& name, T* ptr) const;
522 #endif
523 
525 
527 
528 
534  void print() const;
535 
538  std::ostream& print(std::ostream& os, const PrintOptions &printOptions) const;
539 
542  std::ostream& print(std::ostream& os, int indent = 0, bool showTypes = false, bool showFlags = true ) const;
543 
545  void unused(std::ostream& os) const;
546 
548  std::string currentParametersString() const;
549 
551 
553 
554 
556  inline ConstIterator begin() const;
557 
559  inline ConstIterator end() const;
560 
562  inline const std::string& name(ConstIterator i) const;
563 
565  inline const ParameterEntry& entry(ConstIterator i) const;
566 
568 
570 
571 
616  void validateParameters(
617  ParameterList const& validParamList,
618  int const depth = 1000,
619  EValidateUsed const validateUsed = VALIDATE_USED_ENABLED,
620  EValidateDefaults const validateDefaults = VALIDATE_DEFAULTS_ENABLED
621  ) const;
622 
660  void validateParametersAndSetDefaults(
661  ParameterList const& validParamList,
662  int const depth = 1000
663  );
664 
666 
667 private: // Functions
668 
670  inline Iterator nonconstBegin();
672  inline Iterator nonconstEnd();
674  inline ParameterEntry& nonconstEntry(Iterator i);
676  void validateEntryExists(const std::string &funcName, const std::string &name,
677  const ParameterEntry *entry) const;
678  // ToDo: Change above function to take Ptr<> instead of raw pointer.
680  template<typename T>
681  void validateEntryType(const std::string &funcName, const std::string &name,
682  const ParameterEntry &entry ) const;
684  void validateEntryIsList(const std::string &name, const ParameterEntry &entry) const;
686  void validateMissingSublistMustExist(const std::string &baselist_name,
687  const std::string &sublist_name, const bool mustAlreadyExist) const;
689  void updateSubListNames(int depth = 0);
690 
691 private: // Data members
692 
694  std::string name_;
695 
697 //use pragmas to disable some false-positive warnings for windows sharedlibs export
698 //#ifdef _MSC_VER
699 //#pragma warning(push)
700 //#pragma warning(disable:4251)
701 //#endif
702  params_t params_;
703 //#ifdef _MSC_VER
704 //#pragma warning(pop)
705 //#endif
706 
708  bool disableRecursiveValidation_;
709 
710 };
711 
712 
717 inline
719 {
720  return rcp(new ParameterList);
721 }
722 
723 
728 inline
729 RCP<ParameterList> parameterList(const std::string &name)
730 {
731  return rcp(new ParameterList(name));
732 }
733 
734 
739 inline
741 {
742  return rcp(new ParameterList(source));
743 }
744 
745 
750 inline
752 {
753  return rcp(new ParameterList);
754 }
755 
756 
761 inline
762 RCP<ParameterList> createParameterList(const std::string &name)
763 {
764  return rcp(new ParameterList(name));
765 }
766 
767 
772 template<>
773 class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT TypeNameTraits<ParameterList> {
774 public:
775  static std::string name() { return "ParameterList"; }
776  static std::string concreteName( const ParameterList& /*t2*/ )
777  { return name(); }
778 };
779 
780 
785 TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT bool operator==( const ParameterList& list1, const ParameterList& list2 );
786 
787 
792 inline
793 bool operator!=( const ParameterList& list1, const ParameterList& list2 )
794 {
795  return !( list1 == list2 );
796 }
797 
798 
810 TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT bool haveSameValues( const ParameterList& list1, const ParameterList& list2 );
811 
812 
813 // /////////////////////////////////////////////////////
814 // Inline and Template Function Definitions
815 
816 
817 inline
818 ParameterList& ParameterList::setName( const std::string &name_in )
819 {
820  name_ = name_in;
821  return *this;
822 }
823 
824 
825 // Set functions
826 
827 
828 template<typename T>
829 inline
831  std::string const& name_in, T const& value_in, std::string const& docString_in,
832  RCP<const ParameterEntryValidator> const& validator_in
833  )
834 {
836  const Ordinal param_idx = params_.getObjOrdinalIndex(name_in);
837  if (param_idx != SIOVOCB::getInvalidOrdinal()) {
838  Ptr<ParameterEntry> param = params_.getNonconstObjPtr(param_idx);
839  const std::string docString =
840  (docString_in.length() ? docString_in : param->docString());
841  const RCP<const ParameterEntryValidator> validator =
842  (nonnull(validator_in) ? validator_in : param->validator());
843  // Create temp param to validate before setting
844  ParameterEntry param_new(value_in, false, false, docString, validator );
845  if (nonnull(validator)) {
846  validator->validate(param_new, name_in, this->name());
847  }
848  // Strong guarantee: (if exception is thrown, the value is not changed)
849  *param = param_new;
850  }
851  else {
852  ParameterEntry param_new(value_in, false, false, docString_in, validator_in);
853  if (nonnull(param_new.validator())) {
854  param_new.validator()->validate(param_new, name_in, this->name());
855  }
856  params_.setObj(name_in, param_new);
857  }
858  return *this;
859 }
860 
861 
862 inline
864  std::string const& name_in, char value[], std::string const& docString
865  ,RCP<const ParameterEntryValidator> const& validator
866  )
867 { return set(name_in, std::string(value), docString, validator); }
868 
869 
870 inline
872  const std::string& name_in, const char value[], const std::string &docString
873  ,RCP<const ParameterEntryValidator> const& validator
874  )
875 { return set( name_in, std::string(value), docString, validator ); }
876 
877 
878 inline
880  std::string const& name_in, ParameterList const& value, std::string const& /*docString*/
881  )
882 {
883  sublist(name_in) = value;
884  return *this;
885 }
886 
887 
888 inline
889 ParameterList& ParameterList::setEntry(std::string const& name_in, ParameterEntry const& entry_in)
890 {
891  params_.setObj(name_in, entry_in);
892  return *this;
893 }
894 
895 
896 // Get functions
897 
898 
899 template<typename T>
900 T& ParameterList::get(const std::string& name_in, T def_value)
901 {
903  Ordinal param_idx = params_.getObjOrdinalIndex(name_in);
904  if (param_idx == SIOVOCB::getInvalidOrdinal()) {
905  // Param does not exist
906  param_idx = params_.setObj(name_in, ParameterEntry(def_value, true));
907  }
908  Ptr<ParameterEntry> param = params_.getNonconstObjPtr(param_idx);
909  this->template validateEntryType<T>("get", name_in, *param);
910  return getValue<T>(*param);
911 }
912 
913 
914 inline
915 std::string& ParameterList::get(const std::string& name_in, char def_value[])
916 { return get(name_in, std::string(def_value)); }
917 
918 
919 inline
920 std::string& ParameterList::get(const std::string& name_in, const char def_value[])
921 { return get(name_in, std::string(def_value)); }
922 
923 
924 template<typename T>
925 T& ParameterList::get(const std::string& name_in)
926 {
927  ParameterEntry *foundEntry = this->getEntryPtr(name_in);
928  validateEntryExists("get",name_in,foundEntry);
929  this->template validateEntryType<T>("get",name_in,*foundEntry);
930  return getValue<T>(*foundEntry);
931 }
932 
933 
934 template<typename T>
935 const T& ParameterList::get(const std::string& name_in) const
936 {
937  const ParameterEntry *foundEntry = this->getEntryPtr(name_in);
938  validateEntryExists("get",name_in,foundEntry);
939  this->template validateEntryType<T>("get",name_in,*foundEntry);
940  return getValue<T>(*foundEntry);
941 }
942 
943 
944 template<typename T>
945 inline
946 T* ParameterList::getPtr(const std::string& name_in)
947 {
949  const Ordinal param_idx = params_.getObjOrdinalIndex(name_in);
950  if (param_idx != SIOVOCB::getInvalidOrdinal()) {
951  const Ptr<ParameterEntry> param_ptr = params_.getNonconstObjPtr(param_idx);
952  if (param_ptr->isType<T>()) {
953  return &param_ptr->getValue<T>(0);
954  }
955  // Note: The above is inefficinet. You have to do the dynamic_cast twice
956  // (once to see if it is the type and once to do the cast). This could be
957  // made more efficinet by upgrading Teuchos::any to add a any_cast_ptr()
958  // function but I don't think anyone actually uses this function.
959  return 0;
960  }
961  return 0;
962 }
963 
964 
965 template<typename T>
966 inline
967 const T* ParameterList::getPtr(const std::string& name_in) const
968 {
970  const Ordinal param_idx = params_.getObjOrdinalIndex(name_in);
971  if (param_idx != SIOVOCB::getInvalidOrdinal()) {
972  const Ptr<const ParameterEntry> param_ptr = params_.getObjPtr(param_idx);
973  if (param_ptr->isType<T>()) {
974  return &param_ptr->getValue<T>(0);
975  }
976  // Note: The above is inefficinet, see above non-const getPtr() function.
977  return 0;
978  }
979  return 0;
980 }
981 
982 
983 inline
984 ParameterEntry& ParameterList::getEntry(const std::string& name_in)
985 {
986  ParameterEntry *foundEntry = this->getEntryPtr(name_in);
987  validateEntryExists("get", name_in, foundEntry);
988  return *foundEntry;
989 }
990 
991 
992 inline
993 const ParameterEntry& ParameterList::getEntry(const std::string& name_in) const
994 {
995  const ParameterEntry *foundEntry = this->getEntryPtr(name_in);
996  validateEntryExists("get", name_in, foundEntry);
997  return *foundEntry;
998 }
999 
1000 
1001 inline
1003 ParameterList::getEntryPtr(const std::string& name_in)
1004 {
1006  const Ordinal param_idx = params_.getObjOrdinalIndex(name_in);
1007  if (param_idx != SIOVOCB::getInvalidOrdinal()) {
1008  return &*params_.getNonconstObjPtr(param_idx);
1009  }
1010  return 0;
1011 }
1012 
1013 
1014 inline
1015 const ParameterEntry*
1016 ParameterList::getEntryPtr(const std::string& name_in) const
1017 {
1019  const Ordinal param_idx = params_.getObjOrdinalIndex(name_in);
1020  if (param_idx != SIOVOCB::getInvalidOrdinal()) {
1021  return &*params_.getObjPtr(param_idx);
1022  }
1023  return 0;
1024 }
1025 
1026 
1027 inline RCP<ParameterEntry>
1028 ParameterList::getEntryRCP(const std::string& name_in)
1029 {
1031  const Ordinal param_idx = params_.getObjOrdinalIndex(name_in);
1032  if (param_idx != SIOVOCB::getInvalidOrdinal()) {
1033  return rcpFromPtr(params_.getNonconstObjPtr(param_idx));
1034  }
1035  return null;
1036 }
1037 
1038 
1040 ParameterList::getEntryRCP(const std::string& name_in) const
1041 {
1043  const Ordinal param_idx = params_.getObjOrdinalIndex(name_in);
1044  if (param_idx != SIOVOCB::getInvalidOrdinal()) {
1045  return rcpFromPtr(params_.getObjPtr(param_idx));
1046  }
1047  return null;
1048 }
1049 
1050 
1051 // Attribute Functions
1052 
1053 
1054 inline
1055 const std::string& ParameterList::name() const
1056 {
1057  return name_;
1058 }
1059 
1060 
1061 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1062 template<typename T>
1063 bool ParameterList::isType(const std::string& name_in, T* /*ptr*/) const
1064 {
1066  const Ordinal param_idx = params_.getObjOrdinalIndex(name_in);
1067  if (param_idx != SIOVOCB::getInvalidOrdinal()) {
1068  return params_.getObjPtr(param_idx)->isType<T>();
1069  }
1070  return false;
1071 }
1072 #endif
1073 
1074 
1075 template<typename T>
1076 bool ParameterList::isType(const std::string& name_in) const
1077 {
1078  return this->isType(name_in, static_cast<T*>(0));
1079 }
1080 
1081 
1082 // Read-only access to the iterator
1083 
1084 
1086 {
1087  return params_.begin();
1088 }
1089 
1090 
1092 {
1093  return params_.end();
1094 }
1095 
1096 
1097 inline const std::string& ParameterList::name(ConstIterator i) const
1098 {
1099  return (i->first);
1100 }
1101 
1102 
1104 {
1105  return (i->second);
1106 }
1107 
1108 
1109 // private
1110 
1111 
1112 inline ParameterList::Iterator ParameterList::nonconstBegin()
1113 {
1114  return params_.nonconstBegin();
1115 }
1116 
1117 
1118 inline ParameterList::Iterator ParameterList::nonconstEnd()
1119 {
1120  return params_.nonconstEnd();
1121 }
1122 
1123 
1124 inline ParameterEntry& ParameterList::nonconstEntry(Iterator i)
1125 {
1126  return (i->second);
1127 }
1128 
1129 
1130 template<typename T>
1131 inline
1132 void ParameterList::validateEntryType(
1133  const std::string &/*funcName*/, const std::string &name_in,
1134  const ParameterEntry &entry_in
1135  ) const
1136 {
1138  entry_in.getAny().type() != typeid(T), Exceptions::InvalidParameterType
1139  ,"Error! An attempt was made to access parameter \""<<name_in<<"\""
1140  " of type \""<<entry_in.getAny().typeName()<<"\""
1141  "\nin the parameter (sub)list \""<<this->name()<<"\""
1142  "\nusing the incorrect type \""<<TypeNameTraits<T>::name()<<"\"!"
1143  );
1144 }
1145 
1146 
1147 // //////////////////////////////////////
1148 // Helper functions
1149 
1150 
1157 template<typename T>
1158 T& getParameter( ParameterList& l, const std::string& name )
1159 {
1160  return l.template get<T>(name);
1161 }
1162 
1163 
1169 template<typename T>
1170 inline
1171 T& get( ParameterList& l, const std::string& name )
1172 {
1173  return getParameter<T>(l,name);
1174 }
1175 
1176 
1183 template<typename T>
1184 const T& getParameter( const ParameterList& l, const std::string& name )
1185 {
1186  return l.template get<T>(name);
1187 }
1188 
1189 
1197 template<typename T>
1198 inline
1199 T* getParameterPtr( ParameterList& l, const std::string& name )
1200 {
1201  return l.template getPtr<T>(name);
1202 }
1203 
1204 
1212 template<typename T>
1213 inline
1214 const T* getParameterPtr( const ParameterList& l, const std::string& name )
1215 {
1216  return l.template getPtr<T>(name);
1217 }
1218 
1219 
1226 template<typename T>
1227 inline
1228 bool isParameterType( ParameterList& l, const std::string& name )
1229 {
1230  return l.isType( name, (T*)NULL );
1231 }
1232 
1233 
1240 template<typename T>
1241 inline
1242 bool isParameterType( const ParameterList& l, const std::string& name )
1243 {
1244  return l.isType( name, (T*)NULL );
1245 }
1246 
1247 
1259 template<typename T>
1261  const std::string &paramName
1262  ,const Array<T> &array
1263  ,ParameterList *paramList
1264  )
1265 {
1266  TEUCHOS_TEST_FOR_EXCEPT(!paramList);
1267  paramList->set(paramName,toString(array));
1268 }
1269 
1270 
1335 template<typename T>
1337  const ParameterList &paramList
1338  ,const std::string &paramName
1339  ,const int arrayDim = -1
1340  ,const bool mustExist = true
1341  )
1342 {
1343  std::string arrayStr;
1344  if(mustExist) {
1345  arrayStr = getParameter<std::string>(paramList,paramName);
1346  }
1347  else {
1348  const std::string
1349  *arrayStrPtr = getParameterPtr<std::string>(paramList,paramName);
1350  if(arrayStrPtr) {
1351  arrayStr = *arrayStrPtr;
1352  }
1353  else {
1354  return Array<T>(); // Return an empty array
1355  }
1356  }
1357  Array<T> a;
1358  try {
1359  a = fromStringToArray<T>(arrayStr);
1360  }
1361  catch( const InvalidArrayStringRepresentation&) {
1364  ,"Error! The parameter \""<<paramName<<"\"\n"
1365  "in the sublist \""<<paramList.name()<<"\"\n"
1366  "exists, but the std::string value:\n"
1367  "----------\n"
1368  <<arrayStr<<
1369  "\n----------\n"
1370  "is not a valid array represntation!"
1371  );
1372  }
1374  ( ( a.size()>0 && arrayDim>=0 ) && static_cast<int>(a.size())!=arrayDim )
1376  ,"Error! The parameter \""<<paramName<<"\"\n"
1377  "in the sublist \""<<paramList.name()<<"\"\n"
1378  "exists and is a valid array, but the dimension of\n"
1379  "the read in array a.size() = " << a.size() << "\n"
1380  "was not equal to the expected size arrayDim = " << arrayDim << "!"
1381  );
1382  return a;
1383 }
1384 
1385 
1389 inline
1391  const RCP<ParameterList> &paramList, const std::string& name,
1392  bool mustAlreadyExist = false, const std::string& docString = ""
1393  )
1394 {
1395  return rcpWithEmbeddedObjPostDestroy(
1396  &paramList->sublist(name, mustAlreadyExist, docString), paramList, false );
1397 }
1398 
1399 
1403 inline
1405  const RCP<const ParameterList> &paramList, const std::string& name
1406  )
1407 {
1408  return rcpWithEmbeddedObjPostDestroy(
1409  &paramList->sublist(name), paramList, false );
1410 }
1411 
1412 
1416 inline std::ostream& operator<<(std::ostream& os, const ParameterList& l)
1417 {
1418  return l.print(os);
1419 }
1420 
1421 
1422 } // end of Teuchos namespace
1423 
1424 
1425 #endif
Object held as the "value" in the Teuchos::ParameterList std::map.
C++ Standard Library compatable filtered iterator.
Ordinal getObjOrdinalIndex(const std::string &key) const
Get the ordinal index given the string key.
Ptr< const ObjType > getObjPtr(const Ordinal &idx) const
Get a const semi-persisting association with the stored object indexed by ordinal.
Array< T > getArrayFromStringParameter(const ParameterList &paramList, const std::string &paramName, const int arrayDim=-1, const bool mustExist=true)
Get an Array object (with entries of type T) from a parameter holding a std::string representation of...
RCP< ParameterEntry > getEntryRCP(const std::string &name)
Retrieves the RCP for an entry with the name name if it exists.
RCP< ParameterList > createParameterList()
Nonmember constructor.
RCP< ParameterList > createParameterList(const std::string &name)
Nonmember constructor.
ConstIterator begin() const
An iterator pointing to the first entry.
T & get(const std::string &name, T def_value)
Return the parameter&#39;s value, or the default value if it is not there.
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Set a parameter whose value has type T.
bool nonnull(const std::shared_ptr< T > &p)
Returns true if p.get()!=NULL.
This object is held as the "value" in the Teuchos::ParameterList std::map.
const ParameterEntry & entry(ConstIterator i) const
Access to ParameterEntry (i.e., returns i->second)
bool isParameterType(ParameterList &l, const std::string &name)
A templated helper function for determining the type of a parameter entry for a non-const list...
RCP< ParameterList > sublist(const RCP< ParameterList > &paramList, const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
Return a RCP to a sublist in another RCP-ed parameter list.
const T * getParameterPtr(const ParameterList &l, const std::string &name)
A templated helper function for getting a pointer to a parameter from a non-const list...
ParameterEntry * getEntryPtr(const std::string &name)
Retrieves the pointer for an entry with the name name if it exists.
RCP< ParameterList > parameterList()
Nonmember constructor.
ParameterList & setEntry(const std::string &name, const ParameterEntry &entry)
Set a parameter directly as a ParameterEntry.
ConstIterator end() const
An iterator pointing beyond the last entry.
void print() const
Print function to use in debugging in a debugger.
std::ostream & operator<<(std::ostream &os, const ParameterList &l)
Output stream operator for handling the printing of the parameter list.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
bool isParameterType(const ParameterList &l, const std::string &name)
A templated helper function for determining the type of a parameter entry for a const list...
bool operator!=(const ParameterList &list1, const ParameterList &list2)
Returns true if two parameter lists are not the same.
RCP< ParameterList > parameterList(const ParameterList &source)
Nonmember constructor.
size_type size() const
params_t::ConstIterator ConstIterator
Parameter container const iterator typedef.
const T & getParameter(const ParameterList &l, const std::string &name)
A templated helper function for getting a parameter from a const list. This helper function prevents ...
bool isType(const std::string &name) const
Whether the given parameter exists in this list and has type T.
Utility class for setting and passing in print options.
T & getParameter(ParameterList &l, const std::string &name)
A templated helper function for getting a parameter from a non-const list. This helper function preve...
RCP< const ParameterList > sublist(const RCP< const ParameterList > &paramList, const std::string &name)
Return a RCP to a sublist in another RCP-ed parameter list.
T * getParameterPtr(ParameterList &l, const std::string &name)
A templated helper function for getting a pointer to a parameter from a non-const list...
RCP< const ParameterEntryValidator > validator() const
Return the (optional) validator object.
T * getPtr(const std::string &name)
Retrieves the pointer for parameter name of type T from a list. A null pointer is returned if this pa...
A list of parameters of arbitrary type.
Provides std::map class for deficient platforms.
const std::string & name() const
The name of this ParameterList.
Templated array class derived from the STL std::vector.
Ordinal setObj(const std::string &key, const ObjType &obj)
Set (or reset) object by value and return its ordinal index.
Default traits class that just returns typeid(T).name().
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos, as well as a number of utility routines.
void setStringParameterFromArray(const std::string &paramName, const Array< T > &array, ParameterList *paramList)
Set a std::string parameter representation of an array.
EValidateDefaults
Validation defaults enum.
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
Creates an empty sublist and returns a reference to the sublist name. If the list already exists...
ParameterList & setName(const std::string &name)
Set the name of *this list.
Smart reference counting pointer class for automatic garbage collection.
ParameterEntry & getEntry(const std::string &name)
Retrieves an entry with the name name.
Ptr< ObjType > getNonconstObjPtr(const Ordinal &idx)
Get a nonconst semi-persisting association with the stored object indexed by ordinal.
EValidateUsed
Validation used enum.
RCP< ParameterList > parameterList(const std::string &name)
Nonmember constructor.
Reference-counted pointer class and non-member templated function implementations.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
This macro is designed to be a short version of TEUCHOS_TEST_FOR_EXCEPTION() that is easier to call...
Simple wrapper class for raw pointers to single objects where no persisting relationship exists...
#define TEUCHOS_TEST_FOR_EXCEPTION_PURE_MSG(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
Replacement for std::vector that is compatible with the Teuchos Memory Management classes...