00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef TEUCHOS_PARAMETER_ENTRY_H
00031 #define TEUCHOS_PARAMETER_ENTRY_H
00032
00037 #include "Teuchos_ConfigDefs.hpp"
00038 #include "Teuchos_any.hpp"
00039
00048 namespace Teuchos {
00049
00050 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00051 class ParameterList;
00052 #endif
00053
00054 class ParameterEntry {
00055
00056 public:
00058
00060 ParameterEntry();
00061
00063 ParameterEntry(const ParameterEntry& source);
00064
00066 template<typename T>
00067 ParameterEntry(T value, bool isDefault = false)
00068 : val_(value),
00069 isUsed_(false),
00070 isDefault_(isDefault)
00071 {}
00072
00074 ~ParameterEntry() {};
00075
00077
00079
00081 ParameterEntry& operator=(const ParameterEntry& source);
00082
00090 template<typename T>
00091 void setValue(T value, bool isDefault = false)
00092 {
00093 val_ = value;
00094 isDefault_ = isDefault;
00095 }
00096
00098 ParameterList& setList(bool isDefault = false);
00099
00101
00103
00109 template<typename T>
00110 T& getValue(T *ptr) const
00111 {
00112 isUsed_ = true;
00113 return const_cast<T&>(Teuchos::any_cast<T>( val_ ));
00114 }
00115
00117
00119
00121 bool isUsed() const { return isUsed_; }
00122
00124 bool isList() const { return isList_; }
00126
00128
00135 ostream& leftshift(ostream& os) const;
00137
00138 private:
00139
00141 void reset();
00142
00144 any val_;
00145
00147 bool isList_;
00148
00150 mutable bool isUsed_;
00151
00153 mutable bool isDefault_;
00154
00155 };
00156
00162 template<typename T>
00163 T& getValue( const ParameterEntry &entry )
00164 {
00165 return entry.getValue((T*)NULL);
00166 }
00167
00171 inline ostream& operator<<(ostream& os, const ParameterEntry& e)
00172 {
00173 return e.leftshift(os);
00174 }
00175
00176 }
00177
00178
00179 #endif