Changeset 1611 for code/branches/core3/src/core/ConfigValueContainer.h
- Timestamp:
- Jun 19, 2008, 5:02:45 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core3/src/core/ConfigValueContainer.h
r1610 r1611 95 95 { 96 96 public: 97 ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& varname, const MultiTypeMath& defvalue); 98 ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& varname, const std::vector<MultiTypeMath>& defvalue); 97 /** 98 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. 99 @param type The type of the corresponding config-file 100 @param identifier The identifier of the class the variable belongs to 101 @param varname The name of the variable 102 @param defvalue The default-value 103 @param value Only needed do determine the right type. 104 */ 105 template <class D, class V> 106 ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& varname, const D& defvalue, const V& value) 107 { 108 this->init(type, identifier, varname); 109 this->initValue((V)defvalue); 110 } 111 112 /** 113 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. 114 @param type The type of the corresponding config-file 115 @param identifier The identifier of the class the variable belongs to 116 @param varname The name of the variable 117 @param defvalue The default-value 118 */ 119 template <class V> 120 ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& varname, const std::vector<V>& defvalue) 121 { 122 this->init(type, identifier, varname); 123 124 this->value_ = V(); 125 for (unsigned int i = 0; i < defvalue.size(); i++) 126 this->valueVector_.push_back(MultiTypeMath(defvalue[i])); 127 128 this->initVector(); 129 } 130 99 131 ~ConfigValueContainer(); 100 132 101 /** @brief Returns the configured value. @param value A pointer to the variable to store the value. @return The ConfigValueContainer */ 133 /** 134 @brief Returns the configured value. 135 @param value A pointer to the variable to store the value. 136 @param object The object calling this function 137 @return The ConfigValueContainer 138 */ 102 139 template <typename T, class C> 103 140 ConfigValueContainer& getValue(T* value, C* object) 104 141 { 105 std::cout << "start: " << this->getName() << std::endl;106 142 if ((this->callback_ && object) || this->bContainerIsNew_) 107 143 { … … 123 159 this->value_.getValue(value); 124 160 } 125 std::cout << "end" << std::endl;126 161 return *this; 127 162 } 128 163 129 /** @brief Returns the configured vector. @param value A pointer to the vector to store the values. @return The ConfigValueContainer */ 164 /** 165 @brief Returns the configured vector. 166 @param value A pointer to the vector to store the values. 167 @param object The object calling this function 168 @return The ConfigValueContainer 169 */ 130 170 template <typename T, class C> 131 171 ConfigValueContainer& getValue(std::vector<T>* value, C* object) … … 172 212 } 173 213 174 template <typename T> 175 inline void setVectorType(const std::vector<T>& value) 176 { 177 this->value_ = T(); 178 this->update(); 179 } 180 214 /** @brief Returns the name of this container. */ 181 215 inline const std::string& getName() const 182 216 { return this->varname_; } 217 /** @brief Returns true if this config-value is a vector */ 183 218 inline bool isVector() const 184 219 { return this->bIsVector_; } 220 /** @brief Returns the vectors size (or zero if it's not a vector). */ 185 221 inline unsigned int getVectorSize() const 186 222 { return this->valueVector_.size(); } … … 189 225 const std::string& getDescription() const; 190 226 227 /** 228 @brief Adds a callback function, that gets called after getValue() if the newly assigned value differs from the old value of the variable. 229 @param object The object to call the function 230 @param function The callback function 231 */ 191 232 template <class T> 192 233 inline ConfigValueContainer& callback(T* object, void (T::*function) (void)) … … 225 266 226 267 private: 268 void init(ConfigFileType type, Identifier* identifier, const std::string& varname); 269 void initValue(const MultiTypeMath& defvalue); 270 void initVector(); 227 271 bool callFunctionWithIndex(bool (ConfigValueContainer::* function) (unsigned int, const MultiTypeMath&), const std::string& input); 228 272
Note: See TracChangeset
for help on using the changeset viewer.