Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 11, 2010, 12:34:00 AM (14 years ago)
Author:
landauf
Message:

merged doc branch back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/core/ConfigValueIncludes.h

    r7166 r7401  
    2828
    2929/**
    30 @file
    31 @brief
    32     Definition of macros and functions for config-values.
     30    @defgroup ConfigFile Config file
     31    @ingroup Config
     32*/
     33
     34/**
     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
    3398*/
    3499
Note: See TracChangeset for help on using the changeset viewer.