Changeset 1611 for code/branches/core3
- Timestamp:
- Jun 19, 2008, 5:02:45 AM (17 years ago)
- Location:
- code/branches/core3/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core3/src/core/ConfigValueContainer.cc
r1610 r1611 47 47 { 48 48 /** 49 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. 50 @param type The type of the corresponding config-file 51 @param identifier The identifier of the class the variable belongs to 52 @param varname The name of the variable 53 @param defvalue The default-value 54 */ 55 ConfigValueContainer::ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& varname, const MultiTypeMath& defvalue) 49 @brief Initializes the ConfigValueContainer with defaultvalues. 50 */ 51 void ConfigValueContainer::init(ConfigFileType type, Identifier* identifier, const std::string& varname) 56 52 { 57 53 this->type_ = type; … … 63 59 this->bDoInitialCallback_ = false; 64 60 this->bAddedDescription_ = false; 65 61 } 62 63 /** 64 @brief Does some special initialization for single config-values. 65 */ 66 void ConfigValueContainer::initValue(const MultiTypeMath& defvalue) 67 { 66 68 this->value_ = defvalue; 67 69 this->bIsVector_ = false; 68 70 69 this->defvalueString_ = defvalue.toString();71 this->defvalueString_ = this->value_.toString(); 70 72 this->update(); 71 73 } 72 74 73 75 /** 74 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. 75 @param type The type of the corresponding config-file 76 @param identifier The identifier of the class the variable belongs to 77 @param varname The name of the variable 78 @param defvalue The default-value 79 */ 80 ConfigValueContainer::ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& varname, const std::vector<MultiTypeMath>& defvalue) 81 { 82 this->type_ = type; 83 this->identifier_ = identifier; 84 this->sectionname_ = identifier->getName(); 85 this->varname_ = varname; 86 this->callback_ = 0; 87 this->bContainerIsNew_ = true; 88 this->bDoInitialCallback_ = false; 89 this->bAddedDescription_ = false; 90 91 this->valueVector_ = defvalue; 76 @brief Does some special initialization for vector config-values. 77 */ 78 void ConfigValueContainer::initVector() 79 { 92 80 this->bIsVector_ = true; 93 81 94 if (defvalue.size() > 0) 95 { 96 this->value_ = defvalue[0]; 97 98 for (unsigned int i = 0; i < defvalue.size(); i++) 99 { 100 ConfigFileManager::getSingleton()->getValue(this->type_, this->sectionname_, this->varname_, i, defvalue[i].toString(), this->value_.isA(MT_string)); 101 this->defvalueStringVector_.push_back(defvalue[i].toString()); 102 } 103 104 this->update(); 105 } 82 for (unsigned int i = 0; i < this->valueVector_.size(); i++) 83 { 84 ConfigFileManager::getSingleton()->getValue(this->type_, this->sectionname_, this->varname_, i, this->valueVector_[i].toString(), this->value_.isA(MT_string)); 85 this->defvalueStringVector_.push_back(this->valueVector_[i].toString()); 86 } 87 88 this->update(); 106 89 } 107 90 -
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 -
code/branches/core3/src/core/ConfigValueIncludes.h
r1596 r1611 47 47 @param defvalue The default-value of the variable 48 48 */ 49 #define SetConfigValue (varname, defvalue) \49 #define SetConfigValueGeneric(type, varname, defvalue) \ 50 50 static orxonox::Identifier* identifier##varname = this->getIdentifier(); \ 51 51 orxonox::ConfigValueContainer* container##varname = identifier##varname->getConfigValueContainer(#varname); \ 52 52 if (!container##varname) \ 53 53 { \ 54 container##varname = new orxonox::ConfigValueContainer(CFT_Settings, identifier##varname, #varname, varname = defvalue); \54 container##varname = new orxonox::ConfigValueContainer(CFT_Settings, identifier##varname, #varname, defvalue, varname); \ 55 55 identifier##varname->addConfigValueContainer(#varname, container##varname); \ 56 56 } \ 57 57 container##varname->getValue(&varname, this) 58 58 59 /** 60 @brief Assigns the value, defined in the config-file, to the variable (or the default-value, if there is no entry in the file). 61 @param classname name in which the config value should be stored 62 @param varname The name of the variable 63 @param defvalue The default-value of the variable 64 */ 65 #define SetConfigValueGeneric(classname, varname, defvalue) \ 66 static orxonox::Identifier* identifier##varname = ClassIdentifier<classname>::getIdentifier(); \ 67 orxonox::ConfigValueContainer* container##varname = identifier##varname->getConfigValueContainer(#varname); \ 68 if (!container##varname) \ 69 { \ 70 container##varname = new orxonox::ConfigValueContainer(CFT_Settings, identifier##varname, #varname, varname = defvalue); \ 71 identifier##varname->addConfigValueContainer(#varname, container##varname); \ 72 } \ 73 container##varname->getValue(&varname, this) 59 #define SetConfigValue(varname, defvalue) SetConfigValueGeneric(CFT_Settings, varname, defvalue) 60 #define SetKeybindingValue(varname, defvalue) SetConfigValueGeneric(CFT_Keybindings, varname, defvalue) 61 74 62 75 63 /** … … 78 66 @param defvalue The default-value 79 67 */ 80 #define SetConfigValueVector (varname, defvalue) \68 #define SetConfigValueVectorGeneric(type, varname, defvalue) \ 81 69 static orxonox::Identifier* identifier##varname = this->getIdentifier(); \ 82 70 orxonox::ConfigValueContainer* container##varname = identifier##varname->getConfigValueContainer(#varname); \ 83 71 if (!container##varname) \ 84 72 { \ 85 std::vector<MultiTypeMath> temp; \ 86 for (unsigned int i = 0; i < defvalue.size(); i++) \ 87 temp.push_back(MultiTypeMath(defvalue[i])); \ 88 container##varname = new orxonox::ConfigValueContainer(CFT_Settings, identifier##varname, #varname, temp); \ 89 container##varname->setVectorType(varname); \ 73 container##varname = new orxonox::ConfigValueContainer(CFT_Settings, identifier##varname, #varname, defvalue); \ 90 74 identifier##varname->addConfigValueContainer(#varname, container##varname); \ 91 75 } \ 92 76 container##varname->getValue(&varname, this) 77 78 #define SetConfigValueVector(varname, defvalue) SetConfigValueVectorGeneric(CFT_Settings, varname, defvalue) 79 #define SetKeybindingValueVector(varname, defvalue) SetConfigValueVectorGeneric(CFT_Keybindings, varname, defvalue) 80 93 81 94 82 /** … … 107 95 COUT(2) << "Warning: Couldn't reset config-value '" << #varname << "', corresponding container doesn't exist." << std::endl; \ 108 96 } 97 109 98 110 99 /** -
code/branches/core3/src/core/input/KeyBinder.cc
r1597 r1611 268 268 if (!cont) 269 269 { 270 cont = new ConfigValueContainer(CFT_Keybindings, ClassIdentifier<KeyBinder>::getIdentifier(), button.name_, "" );270 cont = new ConfigValueContainer(CFT_Keybindings, ClassIdentifier<KeyBinder>::getIdentifier(), button.name_, "", button.name_); 271 271 ClassIdentifier<KeyBinder>::getIdentifier()->addConfigValueContainer(button.name_, cont); 272 272 } -
code/branches/core3/src/orxonox/objects/WorldEntity.cc
r1610 r1611 112 112 BaseObject::XMLPort(xmlelement, mode); 113 113 114 std::cout << "111111111111111\n";115 114 XMLPortParamExternTemplate(WorldEntity, Ogre::Node, this->node_, "position", setPosition, getPosition, xmlelement, mode, Ogre::Node, const Vector3&); 116 std::cout << "222222222222222\n";117 115 XMLPortParamLoadOnly(WorldEntity, "direction", setDirectionSimple, xmlelement, mode); 118 116 XMLPortParamLoadOnly(WorldEntity, "yawpitchroll", setYawPitchRoll, xmlelement, mode);
Note: See TracChangeset
for help on using the changeset viewer.