Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 14, 2008, 3:42:49 AM (16 years ago)
Author:
landauf
Message:

merged core2 back to trunk
there might be some errors, wasn't able to test it yet due to some strange g++ and linker behaviour.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/core/ConfigValueContainer.h

    r871 r1052  
    4343#define _ConfigValueContainer_H__
    4444
    45 #include <list>
    4645#include <string>
     46#include <vector>
    4747
    4848#include "CorePrereqs.h"
     
    5050#include "util/Math.h"
    5151#include "util/MultiTypeMath.h"
     52#include "ConfigFileManager.h"
    5253
    5354namespace orxonox
     
    7273    {
    7374        public:
    74             ConfigValueContainer(const std::string& classname, const std::string& varname, MultiTypeMath defvalue);
     75            ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& varname, const MultiTypeMath& defvalue);
     76            ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& varname, const std::vector<MultiTypeMath>& defvalue);
    7577
    7678            /** @brief Returns the configured value. @param value This is only needed to determine the right type. @return The value */
    77 /*            template <typename T>
    78             inline ConfigValueContainer& getValue(T& value)                           { this->value_.getValue(value); return *this; }
    79 */
    80             inline ConfigValueContainer& getValue(int* value)            { this->value_.getValue(value); return *this; }
    81             inline ConfigValueContainer& getValue(unsigned int* value)   { this->value_.getValue(value); return *this; }
    82             inline ConfigValueContainer& getValue(char* value)           { this->value_.getValue(value); return *this; }
    83             inline ConfigValueContainer& getValue(unsigned char* value)  { this->value_.getValue(value); return *this; }
    84             inline ConfigValueContainer& getValue(short* value)          { this->value_.getValue(value); return *this; }
    85             inline ConfigValueContainer& getValue(unsigned short* value) { this->value_.getValue(value); return *this; }
    86             inline ConfigValueContainer& getValue(long* value)           { this->value_.getValue(value); return *this; }
    87             inline ConfigValueContainer& getValue(unsigned long* value)  { this->value_.getValue(value); return *this; }
    88             inline ConfigValueContainer& getValue(float* value)          { this->value_.getValue(value); return *this; }
    89             inline ConfigValueContainer& getValue(double* value)         { this->value_.getValue(value); return *this; }
    90             inline ConfigValueContainer& getValue(long double* value)    { this->value_.getValue(value); return *this; }
    91             inline ConfigValueContainer& getValue(bool* value)           { this->value_.getValue(value); return *this; }
    92             inline ConfigValueContainer& getValue(std::string* value)    { this->value_.getValue(value); return *this; }
    93             inline ConfigValueContainer& getValue(const char** value)    { this->value_.getValue(value); return *this; }
    94             inline ConfigValueContainer& getValue(Vector2* value)        { this->value_.getValue(value); return *this; }
    95             inline ConfigValueContainer& getValue(Vector3* value)        { this->value_.getValue(value); return *this; }
    96             inline ConfigValueContainer& getValue(ColourValue* value)    { this->value_.getValue(value); return *this; }
    97             inline ConfigValueContainer& getValue(Quaternion* value)     { this->value_.getValue(value); return *this; }
    98             inline ConfigValueContainer& getValue(Radian* value)         { this->value_.getValue(value); return *this; }
    99             inline ConfigValueContainer& getValue(Degree* value)         { this->value_.getValue(value); return *this; }
     79            template <typename T>
     80            inline ConfigValueContainer& getValue(T* value)
     81                { this->value_.getValue(value); return *this; }
     82            template <typename T>
     83            inline ConfigValueContainer& getValue(std::vector<T>* value)
     84            {
     85                value->clear();
     86                for (unsigned int i = 0; i < this->valueVector_.size(); i++)
     87                    value->push_back(this->valueVector_[i]);
     88                return *this;
     89            }
     90
     91            inline const std::string& getName() const
     92                { return this->varname_; }
     93            inline bool isVector() const
     94                { return this->bIsVector_; }
     95            inline unsigned int getVectorSize() const
     96                { return this->valueVector_.size(); }
    10097
    10198            void description(const std::string& description);
    10299            const std::string& getDescription() const;
    103100
    104             bool parseString(const std::string& input, MultiTypeMath& defvalue);
    105             bool valueToString(std::string* output, MultiTypeMath& input);
    106             void resetConfigFileEntry();
    107             void resetConfigValue();
     101            bool add(const std::string& input);
     102            bool remove(unsigned int index);
     103            bool set(const std::string& input);
     104            bool tset(const std::string& input);
     105            bool reset();
     106            void update();
    108107
    109             static std::string getStrippedLine(const std::string& line);
    110             static bool isEmpty(const std::string& line);
    111             static bool isComment(const std::string& line);
     108            /** @brief Converts the config-value to a string. @return The string */
     109            inline std::string toString() const
     110                { return this->value_.toString(); }
     111            /** @brief Returns the typename of the assigned config-value. @return The typename */
     112            inline std::string getTypename() const
     113                { return this->value_.getTypename(); }
    112114
    113115        private:
    114             bool parseString(const std::string& input, int defvalue);
    115             bool parseString(const std::string& input, unsigned int defvalue);
    116             bool parseString(const std::string& input, char defvalue);
    117             bool parseString(const std::string& input, unsigned char defvalue);
    118             bool parseString(const std::string& input, short defvalue);
    119             bool parseString(const std::string& input, unsigned short defvalue);
    120             bool parseString(const std::string& input, long defvalue);
    121             bool parseString(const std::string& input, unsigned long defvalue);
    122             bool parseString(const std::string& input, float defvalue);
    123             bool parseString(const std::string& input, double defvalue);
    124             bool parseString(const std::string& input, long double defvalue);
    125             bool parseString(const std::string& input, bool defvalue);
    126             bool parseString(const std::string& input, const std::string& defvalue);
    127             bool parseString(const std::string& input, const char* defvalue);
    128             bool parseString(const std::string& input, const Vector2& defvalue);
    129             bool parseString(const std::string& input, const Vector3& defvalue);
    130             bool parseString(const std::string& input, const ColourValue& defvalue);
    131             bool parseString(const std::string& input, const Quaternion& defvalue);
    132             bool parseString(const std::string& input, const Radian& defvalue);
    133             bool parseString(const std::string& input, const Degree& defvalue);
     116            bool parse(const std::string& input);
     117            bool parse(const std::string& input, const MultiTypeMath& defvalue);
    134118
    135             static std::list<std::string>& getConfigFileLines();
    136             static bool finishedReadingConfigFile(bool finished = false);
    137             void searchConfigFileLine();
    138             std::string parseValueString(bool bStripped = true);
     119            bool set(unsigned int index, const std::string& input);
     120            bool tset(unsigned int index, const std::string& input);
     121            bool parse(unsigned int index, const std::string& input);
     122            bool parse(unsigned int index, const std::string& input, const MultiTypeMath& defvalue);
    139123
    140             static void readConfigFile(const std::string& filename);
    141             static void writeConfigFile(const std::string& filename);
     124            bool                       bIsVector_;                  //!< True if the container contains a std::vector
    142125
    143             std::string         classname_;                     //!< The name of the class the variable belongs to
    144             std::string         varname_;                       //!< The name of the variable
    145             std::string         defvalueString_;                //!< The string of the default-variable
     126            ConfigFileType             type_;                       //!< The type of the corresponding config-file
     127            Identifier*                identifier_;                 //!< The identifier of the class
     128            std::string                sectionname_;                //!< The name of the class the variable belongs to
     129            std::string                varname_;                    //!< The name of the variable
     130            std::string                defvalueString_;             //!< The string of the default-value
     131            std::vector<std::string>   defvalueStringVector_;       //!< A vector, containg the strings of the default-values in case we're storing a vector
    146132
    147             MultiTypeMath       value_;                         //!< The value
     133            MultiTypeMath              value_;                      //!< The value
     134            std::vector<MultiTypeMath> valueVector_;                //!< A vector, containg the values in case we're storing a vector
    148135
    149             std::list<std::string>::iterator configFileLine_;   //!< An iterator, pointing to the entry of the variable in the config-file
    150 
    151             bool bAddedDescription_;                            //!< True if a description was added
    152             LanguageEntryLabel description_;                    //!< The description
     136            bool                       bAddedDescription_;          //!< True if a description was added
     137            LanguageEntryLabel         description_;                //!< The description
    153138    };
    154139}
Note: See TracChangeset for help on using the changeset viewer.