- Timestamp:
- Sep 7, 2010, 12:58:52 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/doc/src/libraries/core/ConfigValueIncludes.h
r7363 r7372 33 33 34 34 /** 35 @file 36 @ingroup Config ConfigFile 37 @brief 38 Definition of macros and functions for config-values. 35 @file 36 @ingroup Config ConfigFile 37 @brief Definition of macros and functions for config-values. 38 39 An example of how to use SetConfigValue(): 40 41 Definition of a class in the header-file: 42 @code 43 class MyClass : public BaseObject 44 { 45 public: 46 MyClass(); // Constructor 47 void setConfigValues(); // Inherited function 48 49 const std::string& getName() 50 { return this->name_; } 51 52 float getVersion() 53 { return this->version_; } 54 55 private: 56 std::string name_; 57 float version_; 58 }; 59 @endcode 60 61 Implementation of the class source-file: 62 @code 63 MyClass::MyClass() 64 { 65 // Macro-call to create an Identifier 66 RegisterObject(MyClass); 67 68 // Function-call to assign the config-values to the new object 69 this->setConfigValues(); 70 } 71 72 void MyClass::setConfigValues() 73 { 74 SetConfigValue(name_, "Orxonox").description("The name of the game"); 75 SetConfigValue(version_, "1.0").description("The version-number"); 76 } 77 @endcode 78 79 Extract of orxonox.ini: 80 @code 81 [MyClass] 82 name_ = "Orxonox" 83 version_ = 1.1 // We have changed this value from 1.0 to 1.1 84 @endcode 85 86 Some other code: 87 @code 88 MyObject orxonoxobject; 89 std::cout << "Name: " << orxonoxobject.getName() << std::endl; 90 std::cout << "Version: " << orxonoxobject.getVersion() << std::endl; 91 @endcode 92 93 Output: 94 @code 95 Name: Orxonox 96 Version: 1.1 97 @endcode 39 98 */ 40 99
Note: See TracChangeset
for help on using the changeset viewer.