Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 30, 2008, 5:38:03 AM (16 years ago)
Author:
landauf
Message:
  • added set and tset functions to the ConfigValueContainer to (temporary) set a config-value to a new value
  • ConfigValueContainer uses now the functions of MultiTypeMath to convert and assign values
  • added some errorhandling to the CommandExecutor in case there are not enough parameters when executing the command
  • added updateConfigValues function to Identifier
  • added addTime and removeTime functions to the Timer
  • some changes in Executor to allow adding description and default-values when using the ConsoleCommand macro
File:
1 edited

Legend:

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

    r947 r957  
    7272    {
    7373        public:
    74             ConfigValueContainer(const std::string& classname, const std::string& varname, MultiTypeMath defvalue);
     74            ConfigValueContainer(Identifier* identifier, const std::string& varname, MultiTypeMath defvalue);
    7575
    7676            /** @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; }
     77            template <typename T>
     78            inline ConfigValueContainer& getValue(T* value)
     79                { this->value_.getValue(value); return *this; }
    10080
    10181            void description(const std::string& description);
    10282            const std::string& getDescription() const;
    10383
    104             bool parseString(const std::string& input, const MultiTypeMath& defvalue = MT_null);
    105             bool valueToString(std::string* output, MultiTypeMath& input);
    106             void resetConfigFileEntry();
    107             void resetConfigValue();
     84            bool set(const std::string& input);
     85            bool tset(const std::string& input);
     86            bool reset();
    10887
    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);
    112 
     88            /** @brief Converts the config-value to a string. @return The string */
     89            inline std::string toString() const
     90                { return this->value_.toString(); }
     91            /** @brief Returns the typename of the assigned config-value. @return The typename */
    11392            inline std::string getTypename() const
    11493                { return this->value_.getTypename(); }
    11594
    11695        private:
    117             bool parseString(const std::string& input, int defvalue);
    118             bool parseString(const std::string& input, unsigned int defvalue);
    119             bool parseString(const std::string& input, char defvalue);
    120             bool parseString(const std::string& input, unsigned char defvalue);
    121             bool parseString(const std::string& input, short defvalue);
    122             bool parseString(const std::string& input, unsigned short defvalue);
    123             bool parseString(const std::string& input, long defvalue);
    124             bool parseString(const std::string& input, unsigned long defvalue);
    125             bool parseString(const std::string& input, float defvalue);
    126             bool parseString(const std::string& input, double defvalue);
    127             bool parseString(const std::string& input, long double defvalue);
    128             bool parseString(const std::string& input, bool defvalue);
    129             bool parseString(const std::string& input, const std::string& defvalue);
    130             bool parseString(const std::string& input, const char* defvalue);
    131             bool parseString(const std::string& input, const Vector2& defvalue);
    132             bool parseString(const std::string& input, const Vector3& defvalue);
    133             bool parseString(const std::string& input, const ColourValue& defvalue);
    134             bool parseString(const std::string& input, const Quaternion& defvalue);
    135             bool parseString(const std::string& input, const Radian& defvalue);
    136             bool parseString(const std::string& input, const Degree& defvalue);
    137 
     96            static void readConfigFile(const std::string& filename);
     97            static void writeConfigFile(const std::string& filename);
    13898            static std::list<std::string>& getConfigFileLines();
    13999            static bool finishedReadingConfigFile(bool finished = false);
    140             void searchConfigFileLine();
    141             std::string parseValueString(bool bStripped = true);
    142100
    143             static void readConfigFile(const std::string& filename);
    144             static void writeConfigFile(const std::string& filename);
     101            bool parse(const std::string& input);
     102            bool parse(const std::string& input, const MultiTypeMath& defvalue);
    145103
    146             std::string         classname_;                     //!< The name of the class the variable belongs to
     104            void setLineInConfigFile(const std::string& input);
     105            void resetLineInConfigFile();
     106            void searchLineInConfigFile();
     107
     108            std::string parseValueStringFromConfigFile(bool bStripped = true);
     109
     110            Identifier*         identifier_;                    //!< The name of the class the variable belongs to
    147111            std::string         varname_;                       //!< The name of the variable
    148112            std::string         defvalueString_;                //!< The string of the default-variable
Note: See TracChangeset for help on using the changeset viewer.