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 explicit 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
00121 const any& getAny() const
00122 {
00123 return val_;
00124 }
00126
00128
00130 bool isUsed() const { return isUsed_; }
00131
00133 bool isList() const { return isList_; }
00134
00142 template <typename T>
00143 bool isType() const
00144 {
00145 return val_.type() == typeid(T);
00146 }
00147
00149 bool isDefault() const {return isDefault_;}
00151
00153
00160 ostream& leftshift(ostream& os) const;
00162
00163 private:
00164
00166 void reset();
00167
00169 any val_;
00170
00172 bool isList_;
00173
00175 mutable bool isUsed_;
00176
00178 mutable bool isDefault_;
00179
00180 };
00181
00187 template<typename T>
00188 T& getValue( const ParameterEntry &entry )
00189 {
00190 return entry.getValue((T*)NULL);
00191 }
00192
00196 inline ostream& operator<<(ostream& os, const ParameterEntry& e)
00197 {
00198 return e.leftshift(os);
00199 }
00200
00201 }
00202
00203
00204 #endif