00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 template<class EnumType>
00022 INLINE ConfigVariableEnum<EnumType>::
00023 ConfigVariableEnum(const string &name, EnumType default_value,
00024 const string &description, int flags) :
00025 #ifdef PRC_SAVE_DESCRIPTIONS
00026 ConfigVariable(name, ConfigVariableCore::VT_enum, description, flags),
00027 #else
00028 ConfigVariable(name, ConfigVariableCore::VT_enum, string(), flags),
00029 #endif
00030 _got_default_value(true),
00031 _default_value(default_value),
00032 _local_modified(initial_invalid_cache())
00033 {
00034 _core->set_default_value(format_enum(default_value));
00035 _core->set_used();
00036 }
00037
00038
00039
00040
00041
00042
00043 template<class EnumType>
00044 INLINE ConfigVariableEnum<EnumType>::
00045 ConfigVariableEnum(const string &name, const string &default_value,
00046 const string &description, int flags) :
00047 #ifdef PRC_SAVE_DESCRIPTIONS
00048 ConfigVariable(name, ConfigVariableCore::VT_enum, description, flags),
00049 #else
00050 ConfigVariable(name, ConfigVariableCore::VT_enum, string(), flags),
00051 #endif
00052 _got_default_value(true),
00053 _default_value(parse_string(default_value)),
00054 _local_modified(initial_invalid_cache())
00055 {
00056 _core->set_default_value(default_value);
00057 _core->set_used();
00058 }
00059
00060
00061
00062
00063
00064
00065 template<class EnumType>
00066 INLINE ConfigVariableEnum<EnumType>::
00067 ~ConfigVariableEnum() {
00068 }
00069
00070
00071
00072
00073
00074
00075 template<class EnumType>
00076 INLINE void ConfigVariableEnum<EnumType>::
00077 operator = (EnumType value) {
00078 set_value(value);
00079 }
00080
00081
00082
00083
00084
00085
00086 template<class EnumType>
00087 INLINE ConfigVariableEnum<EnumType>::
00088 operator EnumType () const {
00089 return get_value();
00090 }
00091
00092
00093
00094
00095
00096
00097 template<class EnumType>
00098 INLINE int ConfigVariableEnum<EnumType>::
00099 size() const {
00100 return get_num_words();
00101 }
00102
00103
00104
00105
00106
00107
00108 template<class EnumType>
00109 INLINE EnumType ConfigVariableEnum<EnumType>::
00110 operator [] (int n) const {
00111 return get_word(n);
00112 }
00113
00114
00115
00116
00117
00118
00119 template<class EnumType>
00120 INLINE void ConfigVariableEnum<EnumType>::
00121 set_value(EnumType value) {
00122 set_string_value(format_enum(value));
00123 }
00124
00125
00126
00127
00128
00129
00130 template<class EnumType>
00131 INLINE EnumType ConfigVariableEnum<EnumType>::
00132 get_value() const {
00133 TAU_PROFILE("EnumType ConfigVariableEnum<EnumType>::get_value() const", " ", TAU_USER);
00134 if (!is_cache_valid(_local_modified)) {
00135 mark_cache_valid(((ConfigVariableEnum<EnumType> *)this)->_local_modified);
00136 ((ConfigVariableEnum<EnumType> *)this)->_cache = (EnumType)parse_string(get_string_value());
00137 }
00138 return _cache;
00139 }
00140
00141
00142
00143
00144
00145
00146 template<class EnumType>
00147 INLINE EnumType ConfigVariableEnum<EnumType>::
00148 get_default_value() const {
00149 if (!_got_default_value) {
00150 const ConfigDeclaration *decl = ConfigVariable::get_default_value();
00151 if (decl != (ConfigDeclaration *)NULL) {
00152 ((ConfigVariableEnum<EnumType> *)this)->_default_value = (EnumType)parse_string(decl->get_string_value());
00153 ((ConfigVariableEnum<EnumType> *)this)->_got_default_value = true;
00154 }
00155 }
00156 return _default_value;
00157 }
00158
00159
00160
00161
00162
00163
00164 template<class EnumType>
00165 INLINE EnumType ConfigVariableEnum<EnumType>::
00166 get_word(int n) const {
00167 return (EnumType)parse_string(get_string_word(n));
00168 }
00169
00170
00171
00172
00173
00174
00175
00176 template<class EnumType>
00177 INLINE void ConfigVariableEnum<EnumType>::
00178 set_word(int n, EnumType value) {
00179 set_string_word(n, format_enum(value));
00180 }
00181
00182
00183
00184
00185
00186
00187
00188
00189 template<class EnumType>
00190 INLINE EnumType ConfigVariableEnum<EnumType>::
00191 parse_string(const string &value) const {
00192 istringstream strm(value);
00193 EnumType result;
00194 strm >> result;
00195 return result;
00196 }
00197
00198
00199
00200
00201
00202
00203
00204
00205 template<class EnumType>
00206 INLINE string ConfigVariableEnum<EnumType>::
00207 format_enum(EnumType value) const {
00208 ostringstream strm;
00209 strm << value;
00210 return strm.str();
00211 }