Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1435


Ignore:
Timestamp:
May 27, 2008, 1:17:33 AM (16 years ago)
Author:
landauf
Message:

after some changes in MultiTypeMath and co., the new config and tconfig commands work very well. they substitute set and tset respectively.

Location:
code/branches/console/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/branches/console/src/core/CommandEvaluation.cc

    r1434 r1435  
    100100        if (!this->bNewCommand_)
    101101        {
    102 std::cout << "not new" << std::endl;
    103102            switch (this->state_)
    104103            {
     
    163162        {
    164163            case CS_Uninitialized:
    165 std::cout << "hint: CS_Uninitialized" << std::endl;
    166164                break;
    167165            case CS_Empty:
    168 std::cout << "hint: CS_Empty" << std::endl;
    169166            case CS_ShortcutOrIdentifier:
    170 std::cout << "hint: CS_ShortcutOrIdentifier" << std::endl;
    171167                if (this->listOfPossibleFunctions_.size() == 0)
    172168                    return CommandEvaluation::dump(this->listOfPossibleIdentifiers_);
     
    177173                break;
    178174            case CS_Function:
    179 std::cout << "hint: CS_Function" << std::endl;
    180175                return CommandEvaluation::dump(this->listOfPossibleFunctions_);
    181176                break;
    182177            case CS_ParamPreparation:
    183 std::cout << "hint: CS_ParamPreparation" << std::endl;
    184178            case CS_Params:
    185 std::cout << "hint: CS_Params" << std::endl;
    186179                if (this->listOfPossibleArguments_.size() > 0)
    187180                    return CommandEvaluation::dump(this->listOfPossibleArguments_);
     
    189182                    return CommandEvaluation::dump(this->function_);
    190183            case CS_Finished:
    191 std::cout << "hint: CS_Finished" << std::endl;
    192184                if (this->function_)
    193185                    return CommandEvaluation::dump(this->function_);
    194186                break;
    195187            case CS_Error:
    196 std::cout << "hint: CS_Error" << std::endl;
    197188                return this->errorMessage_;
    198189                break;
  • code/branches/console/src/core/CommandExecutor.cc

    r1434 r1435  
    126126    void CommandExecutor::parseIfNeeded(const std::string& command)
    127127    {
    128 std::cout << "parse if needed: command:      >" << command << "<" << std::endl;
    129 std::cout << "                 old original: >" << CommandExecutor::getEvaluation().originalCommand_ << "<" << std::endl;
    130 std::cout << "                 old modified: >" << CommandExecutor::getEvaluation().command_ << "<" << std::endl;
    131128        if (CommandExecutor::getEvaluation().state_ == CS_Uninitialized)
    132129        {
    133 std::cout << "parse if needed: parse!" << std::endl;
    134130            CommandExecutor::parse(command);
    135131        }
    136         else if (/*removeTrailingWhitespaces*/(CommandExecutor::getEvaluation().originalCommand_) != /*removeTrailingWhitespaces*/(command))
     132        else if (CommandExecutor::getEvaluation().originalCommand_ != command)
    137133        {
    138134            if (CommandExecutor::getEvaluation().command_ == command)
    139135            {
    140 std::cout << "parse if needed: parse and set bNewCommand_ to false" << std::endl;
    141136                CommandExecutor::parse(command);
    142137                CommandExecutor::getEvaluation().bNewCommand_ = false;
     
    144139            else
    145140            {
    146 std::cout << "parse if needed: parse!" << std::endl;
    147141                CommandExecutor::parse(command);
    148142            }
    149143        }
    150 std::cout << "parse if needed: don't parse" << std::endl;
    151144    }
    152145
     
    163156        {
    164157            case CS_Uninitialized:
    165 std::cout << "0: Uninitialized\n";
    166158            {
    167159                // Impossible
     
    169161            }
    170162            case CS_Empty:
    171 std::cout << "0: Empty\n";
    172163            {
    173164                if (CommandExecutor::argumentsGiven() == 0)
     
    184175            }
    185176            case CS_ShortcutOrIdentifier:
    186 std::cout << "0: ShortcutOrIdentifier\n";
    187177            {
    188178                if (CommandExecutor::argumentsGiven() > 1)
     
    201191                    else if (CommandExecutor::getEvaluation().functionclass_)
    202192                    {
    203 std::cout << "MEP" << std::endl;
    204193                        // It's a functionname
    205194                        CommandExecutor::getEvaluation().state_ = CS_Function;
     
    283272            }
    284273            case CS_Function:
    285 std::cout << "0: Function\n";
    286274            {
    287275                if (CommandExecutor::getEvaluation().functionclass_)
     
    295283                        if (CommandExecutor::getEvaluation().function_)
    296284                        {
    297 std::cout << "MEP2" << std::endl;
    298285                            // It's a function
    299286                            CommandExecutor::getEvaluation().state_ = CS_ParamPreparation;
     
    551538    std::string CommandExecutor::getPossibleArgument(const std::string& name, ConsoleCommand* command, unsigned int param)
    552539    {
    553 std::cout << "4_1\n";
    554540        CommandExecutor::createArgumentCompletionList(command, param);
    555541
    556 std::cout << "4_2\n";
    557542        std::string lowercase = getLowercase(name);
    558 std::cout << "4_3\n";
    559543        for (std::list<std::pair<std::string, std::string> >::const_iterator it = command->getArgumentCompletionListBegin(); it != command->getArgumentCompletionListEnd(); ++it)
    560544        {
    561 std::cout << "4_4\n";
    562545            if ((*it).first == lowercase)
    563546                return (*it).second;
    564547        }
    565548
    566 std::cout << "4_5\n";
    567549        return "";
    568550    }
  • code/branches/console/src/core/ConfigFileManager.cc

    r1434 r1435  
    3939{
    4040    SetConsoleCommandShortcutExtern(config).setArgumentCompleter(0, autocompletion::configvalueclasses()).setArgumentCompleter(1, autocompletion::configvalues()).setArgumentCompleter(2, autocompletion::configvalue());
    41     SetConsoleCommandShortcutExtern(tconfig);
     41    SetConsoleCommandShortcutExtern(tconfig).setArgumentCompleter(0, autocompletion::configvalueclasses()).setArgumentCompleter(1, autocompletion::configvalues()).setArgumentCompleter(2, autocompletion::configvalue());
    4242    SetConsoleCommandShortcutExtern(reloadConfig);
    4343    SetConsoleCommandShortcutExtern(cleanConfig);
     
    4747    bool config(const std::string& classname, const std::string& varname, const std::string& value)
    4848    {
    49 std::cout << "10a_1\n";
    5049        std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseIdentifierMap().find(getLowercase(classname));
    5150        if (identifier != Identifier::getLowercaseIdentifierMapEnd())
    5251        {
    53 std::cout << "10a_2\n";
    5452            std::map<std::string, ConfigValueContainer*>::const_iterator variable = (*identifier).second->getLowercaseConfigValueMap().find(getLowercase(varname));
    5553            if (variable != (*identifier).second->getLowercaseConfigValueMapEnd())
    56             {
    57 std::cout << "10a_3\n";
    58                 return (*variable).second->tset(value);
    59             }
     54                return (*variable).second->set(value);
    6055        }
    6156        return false;
     
    6459    bool tconfig(const std::string& classname, const std::string& varname, const std::string& value)
    6560    {
    66 std::cout << "10b_1\n";
    6761        std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseIdentifierMap().find(getLowercase(classname));
    6862        if (identifier != Identifier::getLowercaseIdentifierMapEnd())
    6963        {
    70 std::cout << "10b_2\n";
    7164            std::map<std::string, ConfigValueContainer*>::const_iterator variable = (*identifier).second->getLowercaseConfigValueMap().find(getLowercase(varname));
    7265            if (variable != (*identifier).second->getLowercaseConfigValueMapEnd())
    73             {
    74 std::cout << "10b_3\n";
    7566                return (*variable).second->tset(value);
    76             }
    7767        }
    7868        return false;
  • code/branches/console/src/util/MultiTypeMath.cc

    r1320 r1435  
    7272}
    7373
     74bool MultiTypeMath::operator==(const MultiTypeString& mts) const
     75{
     76    return MultiTypeString::operator==(mts);
     77}
     78
     79bool MultiTypeMath::operator==(const MultiTypePrimitive& mtp) const
     80{
     81    return MultiTypePrimitive::operator==(mtp);
     82}
     83
    7484bool MultiTypeMath::operator!=(const MultiTypeMath& mtm) const
    7585{
     
    93103
    94104    return true;
     105}
     106
     107bool MultiTypeMath::operator!=(const MultiTypeString& mts) const
     108{
     109    return MultiTypeString::operator!=(mts);
     110}
     111
     112bool MultiTypeMath::operator!=(const MultiTypePrimitive& mtp) const
     113{
     114    return MultiTypePrimitive::operator!=(mtp);
    95115}
    96116
     
    152172}
    153173
     174void MultiTypeMath::setValue(const MultiTypeString& mts)
     175{
     176    MultiTypeString::setValue(mts);
     177}
     178
     179void MultiTypeMath::setValue(const MultiTypePrimitive& mtp)
     180{
     181    MultiTypePrimitive::setValue(mtp);
     182}
     183
    154184std::string MultiTypeMath::getTypename() const
    155185{
     
    218248bool MultiTypeMath::assimilate(const MultiTypeMath& mtm, const MultiTypeMath& defvalue)
    219249{
    220     if (this->type_ == MT_vector2)
     250    if (this->type_ == MT_void)
     251        return ConvertValue(&this->value_.void_, mtm, defvalue.value_.void_);
     252    else if (this->type_ == MT_int)
     253        return ConvertValue(&this->value_.int_, mtm, defvalue.value_.int_);
     254    else if (this->type_ == MT_uint)
     255        return ConvertValue(&this->value_.uint_, mtm, defvalue.value_.uint_);
     256    else if (this->type_ == MT_char)
     257        return ConvertValue(&this->value_.char_, mtm, defvalue.value_.char_);
     258    else if (this->type_ == MT_uchar)
     259        return ConvertValue(&this->value_.uchar_, mtm, defvalue.value_.uchar_);
     260    else if (this->type_ == MT_short)
     261        return ConvertValue(&this->value_.short_, mtm, defvalue.value_.short_);
     262    else if (this->type_ == MT_ushort)
     263        return ConvertValue(&this->value_.ushort_, mtm, defvalue.value_.ushort_);
     264    else if (this->type_ == MT_long)
     265        return ConvertValue(&this->value_.long_, mtm, defvalue.value_.long_);
     266    else if (this->type_ == MT_ulong)
     267        return ConvertValue(&this->value_.ulong_, mtm, defvalue.value_.ulong_);
     268    else if (this->type_ == MT_float)
     269        return ConvertValue(&this->value_.float_, mtm, defvalue.value_.float_);
     270    else if (this->type_ == MT_double)
     271        return ConvertValue(&this->value_.double_, mtm, defvalue.value_.double_);
     272    else if (this->type_ == MT_longdouble)
     273        return ConvertValue(&this->value_.longdouble_, mtm, defvalue.value_.longdouble_);
     274    else if (this->type_ == MT_bool)
     275        return ConvertValue(&this->value_.bool_, mtm, defvalue.value_.bool_);
     276    else if (this->type_ == MT_constchar)
     277        return ConvertValue(&this->string_, mtm, defvalue.string_);
     278    else if (this->type_ == MT_string)
     279        return ConvertValue(&this->string_, mtm, defvalue.string_);
     280    else if (this->type_ == MT_vector2)
    221281        return ConvertValue(&this->vector2_, mtm, defvalue.vector2_);
    222282    else if (this->type_ == MT_vector3)
     
    233293        return ConvertValue(&this->degree_, mtm, defvalue.degree_);
    234294    else
    235         return MultiTypeString::assimilate(mtm, defvalue);
     295        return false;
    236296}
    237297
  • code/branches/console/src/util/MultiTypeMath.h

    r1320 r1435  
    6969        inline MultiTypeMath(const orxonox::Degree&      value) { this->setValue(value); }
    7070        inline MultiTypeMath(const MultiTypeMath& mtm)          { this->setValue(mtm);   }
     71        inline MultiTypeMath(const MultiTypeString& mts)        { this->setValue(mts);   }
     72        inline MultiTypeMath(const MultiTypePrimitive& mtp)     { this->setValue(mtp);   }
    7173        virtual inline ~MultiTypeMath() {}
    7274
     
    8082        inline MultiTypeMath& operator=(const orxonox::Degree&      value) { this->setValue(value); return *this; }
    8183        inline MultiTypeMath& operator=(const MultiTypeMath& mtm)          { this->setValue(mtm);   return *this; }
     84        inline MultiTypeMath& operator=(const MultiTypeString& mts)        { this->setValue(mts);   return *this; }
     85        inline MultiTypeMath& operator=(const MultiTypePrimitive mtp)      { this->setValue(mtp);   return *this; }
    8286
    8387        using MultiTypeString::operator==;
     
    9094        inline bool operator==(const orxonox::Degree&      value) const { return (this->degree_      == value); }
    9195        bool operator==(const MultiTypeMath& mtm) const;
     96        bool operator==(const MultiTypeString& mts) const;
     97        bool operator==(const MultiTypePrimitive& mtp) const;
    9298
    9399        using MultiTypeString::operator!=;
     
    100106        inline bool operator!=(const orxonox::Degree&      value) const { return (this->degree_      != value); }
    101107        bool operator!=(const MultiTypeMath& mtm) const;
     108        bool operator!=(const MultiTypeString& mts) const;
     109        bool operator!=(const MultiTypePrimitive& mtp) const;
    102110
    103111        virtual operator void*()                const;
     
    133141        inline void setValue(const orxonox::Degree&      value) { this->type_ = MT_degree;      this->degree_      = value; }
    134142        void setValue(const MultiTypeMath& mtm);
     143        void setValue(const MultiTypeString& mts);
     144        void setValue(const MultiTypePrimitive& mtp);
    135145
    136146        inline orxonox::Vector2     getVector2()     const { return this->vector2_;     }
  • code/branches/console/src/util/MultiTypeString.cc

    r1320 r1435  
    3333MultiTypeString::MultiTypeString(MultiType type) : MultiTypePrimitive(type)
    3434{
    35     // Nothing to do for string and xml-element
     35    // Nothing to do for string
    3636}
    3737
     
    4949}
    5050
     51bool MultiTypeString::operator==(const MultiTypePrimitive& mtp) const
     52{
     53    return MultiTypePrimitive::operator==(mtp);
     54}
     55
    5156bool MultiTypeString::operator!=(const MultiTypeString& mts) const
    5257{
     
    6065
    6166    return true;
     67}
     68
     69bool MultiTypeString::operator!=(const MultiTypePrimitive& mtp) const
     70{
     71    return MultiTypePrimitive::operator!=(mtp);
    6272}
    6373
     
    97107    MultiTypePrimitive::setValue(mts);
    98108    this->string_ = mts.string_;
     109}
     110
     111void MultiTypeString::setValue(const MultiTypePrimitive& mtp)
     112{
     113    MultiTypePrimitive::setValue(mtp);
    99114}
    100115
     
    138153bool MultiTypeString::assimilate(const MultiTypeString& mts, const MultiTypeString& defvalue)
    139154{
    140     if (this->type_ == MT_constchar)
     155    if (this->type_ == MT_void)
     156        return ConvertValue(&this->value_.void_, mts, defvalue.value_.void_);
     157    else if (this->type_ == MT_int)
     158        return ConvertValue(&this->value_.int_, mts, defvalue.value_.int_);
     159    else if (this->type_ == MT_uint)
     160        return ConvertValue(&this->value_.uint_, mts, defvalue.value_.uint_);
     161    else if (this->type_ == MT_char)
     162        return ConvertValue(&this->value_.char_, mts, defvalue.value_.char_);
     163    else if (this->type_ == MT_uchar)
     164        return ConvertValue(&this->value_.uchar_, mts, defvalue.value_.uchar_);
     165    else if (this->type_ == MT_short)
     166        return ConvertValue(&this->value_.short_, mts, defvalue.value_.short_);
     167    else if (this->type_ == MT_ushort)
     168        return ConvertValue(&this->value_.ushort_, mts, defvalue.value_.ushort_);
     169    else if (this->type_ == MT_long)
     170        return ConvertValue(&this->value_.long_, mts, defvalue.value_.long_);
     171    else if (this->type_ == MT_ulong)
     172        return ConvertValue(&this->value_.ulong_, mts, defvalue.value_.ulong_);
     173    else if (this->type_ == MT_float)
     174        return ConvertValue(&this->value_.float_, mts, defvalue.value_.float_);
     175    else if (this->type_ == MT_double)
     176        return ConvertValue(&this->value_.double_, mts, defvalue.value_.double_);
     177    else if (this->type_ == MT_longdouble)
     178        return ConvertValue(&this->value_.longdouble_, mts, defvalue.value_.longdouble_);
     179    else if (this->type_ == MT_bool)
     180        return ConvertValue(&this->value_.bool_, mts, defvalue.value_.bool_);
     181    else if (this->type_ == MT_constchar)
    141182        return ConvertValue(&this->string_, mts, defvalue.string_);
    142183    else if (this->type_ == MT_string)
    143184        return ConvertValue(&this->string_, mts, defvalue.string_);
    144185    else
    145         return MultiTypePrimitive::assimilate(mts, defvalue);
     186        return false;
    146187}
    147188
  • code/branches/console/src/util/MultiTypeString.h

    r1325 r1435  
    6161        inline MultiTypeString(long double    value) : MultiTypePrimitive(value) {}
    6262        inline MultiTypeString(bool           value) : MultiTypePrimitive(value) {}
    63         inline MultiTypeString(const char*           value) { this->setValue(value); }
    64         inline MultiTypeString(const std::string&    value) { this->setValue(value); }
    65         inline MultiTypeString(const MultiTypeString& mts)  { this->setValue(mts);   }
     63        inline MultiTypeString(const char*             value) { this->setValue(value); }
     64        inline MultiTypeString(const std::string&      value) { this->setValue(value); }
     65        inline MultiTypeString(const MultiTypeString&    mts)  { this->setValue(mts);   }
     66        inline MultiTypeString(const MultiTypePrimitive& mtp)  { this->setValue(mtp);   }
    6667        virtual inline ~MultiTypeString() {}
    6768
    6869        using MultiTypePrimitive::operator=;
    69         inline MultiTypeString& operator=(const char*          value) { this->setValue(value); return *this; }
    70         inline MultiTypeString& operator=(const std::string&   value) { this->setValue(value); return *this; }
    71         inline MultiTypeString& operator=(const MultiTypeString& mts) { this->setValue(mts);   return *this; }
     70        inline MultiTypeString& operator=(const char*             value) { this->setValue(value); return *this; }
     71        inline MultiTypeString& operator=(const std::string&      value) { this->setValue(value); return *this; }
     72        inline MultiTypeString& operator=(const MultiTypeString&    mts) { this->setValue(mts);   return *this; }
     73        inline MultiTypeString& operator=(const MultiTypePrimitive& mtp) { this->setValue(mtp);   return *this; }
    7274
    7375        using MultiTypePrimitive::operator==;
    7476        inline bool operator==(const char*        value) const { return (this->string_ == std::string(value)); }
    7577        inline bool operator==(const std::string& value) const { return (this->string_ == value);              }
    76         bool operator==(const MultiTypeString& mts) const;
     78        bool operator==(const MultiTypeString&    mts) const;
     79        bool operator==(const MultiTypePrimitive& mtp) const;
    7780
    7881        using MultiTypePrimitive::operator!=;
    7982        inline bool operator!=(const char*        value) const { return (this->string_ != std::string(value)); }
    8083        inline bool operator!=(const std::string& value) const { return (this->string_ != value);              }
    81         bool operator!=(const MultiTypeString& mts) const;
     84        bool operator!=(const MultiTypeString&    mts) const;
     85        bool operator!=(const MultiTypePrimitive& mtp) const;
    8286
    8387        virtual operator void*()          const;
     
    100104        inline void setValue(const char*        value) { this->type_ = MT_string; this->string_ = std::string(value); }
    101105        inline void setValue(const std::string& value) { this->type_ = MT_string; this->string_ = value;              }
    102         void setValue(const MultiTypeString& mts);
     106        void setValue(const MultiTypeString&    mts);
     107        void setValue(const MultiTypePrimitive& mtp);
    103108
    104109        inline std::string getString()     const { return this->string_;         }
Note: See TracChangeset for help on using the changeset viewer.