Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 28, 2010, 1:51:04 AM (14 years ago)
Author:
landauf
Message:

replaced the temporary names of all ConsoleCommand related classes and functions by their real names

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.h

    r7228 r7236  
    4141
    4242
    43 #define _SetConsoleCommand(...) \
    44     BOOST_PP_EXPAND(BOOST_PP_CAT(_SetConsoleCommand, ORXONOX_VA_NARGS(__VA_ARGS__))(__VA_ARGS__))
    45 #define _SetConsoleCommand2(name, functionpointer) \
    46     _SetConsoleCommandGeneric("", name, orxonox::createFunctor(functionpointer))
    47 #define _SetConsoleCommand3(group, name, functionpointer) \
    48     _SetConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer))
    49 #define _SetConsoleCommand4(group, name, functionpointer, object) \
    50     _SetConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer, object))
    51 
    52 #define _SetConsoleCommandGeneric(group, name, functor) \
    53     static orxonox::_ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __LINE__) = (*orxonox::_createConsoleCommand(group, name, orxonox::createExecutor(functor)))
    54 
    55 
    56 #define _DeclareConsoleCommand(...) \
    57     BOOST_PP_CAT(_DeclareConsoleCommand, ORXONOX_VA_NARGS(__VA_ARGS__))(__VA_ARGS__)
    58 #define _DeclareConsoleCommand2(name, functionpointer) \
    59     _DeclareConsoleCommandGeneric("", name, orxonox::createFunctor(functionpointer))
    60 #define _DeclareConsoleCommand3(group, name, functionpointer) \
    61     _DeclareConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer))
    62 #define _DeclareConsoleCommand4(group, name, functionpointer, object) \
    63     _DeclareConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer, object))
    64 
    65 #define _DeclareConsoleCommandGeneric(group, name, functor) \
    66     static orxonox::_ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __LINE__) = (*orxonox::_createConsoleCommand(group, name, orxonox::createExecutor(functor), false))
     43#define SetConsoleCommand(...) \
     44    BOOST_PP_EXPAND(BOOST_PP_CAT(SetConsoleCommand, ORXONOX_VA_NARGS(__VA_ARGS__))(__VA_ARGS__))
     45#define SetConsoleCommand2(name, functionpointer) \
     46    SetConsoleCommandGeneric("", name, orxonox::createFunctor(functionpointer))
     47#define SetConsoleCommand3(group, name, functionpointer) \
     48    SetConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer))
     49#define SetConsoleCommand4(group, name, functionpointer, object) \
     50    SetConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer, object))
     51
     52#define SetConsoleCommandGeneric(group, name, functor) \
     53    static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __LINE__) = (*orxonox::createConsoleCommand(group, name, orxonox::createExecutor(functor)))
     54
     55
     56#define DeclareConsoleCommand(...) \
     57    BOOST_PP_CAT(DeclareConsoleCommand, ORXONOX_VA_NARGS(__VA_ARGS__))(__VA_ARGS__)
     58#define DeclareConsoleCommand2(name, functionpointer) \
     59    DeclareConsoleCommandGeneric("", name, orxonox::createFunctor(functionpointer))
     60#define DeclareConsoleCommand3(group, name, functionpointer) \
     61    DeclareConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer))
     62#define DeclareConsoleCommand4(group, name, functionpointer, object) \
     63    DeclareConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer, object))
     64
     65#define DeclareConsoleCommandGeneric(group, name, functor) \
     66    static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __LINE__) = (*orxonox::createConsoleCommand(group, name, orxonox::createExecutor(functor), false))
    6767
    6868
     
    9090    }
    9191
    92     class _CoreExport _ConsoleCommand
     92    class _CoreExport ConsoleCommand
    9393    {
    94         friend struct _ConsoleCommandManipulator;
     94        friend struct ConsoleCommandManipulator;
    9595
    9696        struct Command
     
    101101
    102102        public:
    103             struct _ConsoleCommandManipulator
     103            struct ConsoleCommandManipulator
    104104            {
    105105                public:
    106                     _ConsoleCommandManipulator(const _ConsoleCommand* command) : command_(const_cast<_ConsoleCommand*>(command)) {}
     106                    ConsoleCommandManipulator(const ConsoleCommand* command) : command_(const_cast<ConsoleCommand*>(command)) {}
    107107
    108108                    template <class F>
    109                     inline _ConsoleCommandManipulator& setFunction(F function, bool bForce = false)
     109                    inline ConsoleCommandManipulator& setFunction(F function, bool bForce = false)
    110110                        {
    111111                            if (this->command_)
     
    122122                        }
    123123                    template <class F, class O>
    124                     inline _ConsoleCommandManipulator& setFunction(F function, O* object, bool bForce = false)
     124                    inline ConsoleCommandManipulator& setFunction(F function, O* object, bool bForce = false)
    125125                        {
    126126                            if (this->command_)
     
    137137                            return *this;
    138138                        }
    139                     inline _ConsoleCommandManipulator& setFunction(const FunctorPtr& functor, bool bForce = false)
     139                    inline ConsoleCommandManipulator& setFunction(const FunctorPtr& functor, bool bForce = false)
    140140                        { if (this->command_) { this->command_->setFunction(functor, bForce); } return *this; }
    141                     inline _ConsoleCommandManipulator& setFunction(const ExecutorPtr& executor, bool bForce = false)
     141                    inline ConsoleCommandManipulator& setFunction(const ExecutorPtr& executor, bool bForce = false)
    142142                        { if (this->command_) { this->command_->setFunction(executor, bForce); } return *this; }
    143143
    144144                    template <class F>
    145                     inline _ConsoleCommandManipulator& pushFunction(F function, bool bForce = false)
     145                    inline ConsoleCommandManipulator& pushFunction(F function, bool bForce = false)
    146146                        { if (this->command_) { this->command_->pushFunction(createFunctor(function), bForce); } return *this; }
    147147                    template <class F, class O>
    148                     inline _ConsoleCommandManipulator& pushFunction(F function, O* object, bool bForce = false)
     148                    inline ConsoleCommandManipulator& pushFunction(F function, O* object, bool bForce = false)
    149149                        { if (this->command_) { this->command_->pushFunction(createFunctor(function, object), bForce); } return *this; }
    150                     inline _ConsoleCommandManipulator& pushFunction(const FunctorPtr& functor, bool bForce = false)
     150                    inline ConsoleCommandManipulator& pushFunction(const FunctorPtr& functor, bool bForce = false)
    151151                        { if (this->command_) { this->command_->pushFunction(functor, bForce); } return *this; }
    152                     inline _ConsoleCommandManipulator& pushFunction(const ExecutorPtr& executor, bool bForce = false)
     152                    inline ConsoleCommandManipulator& pushFunction(const ExecutorPtr& executor, bool bForce = false)
    153153                        { if (this->command_) { this->command_->pushFunction(executor, bForce); } return *this; }
    154154
    155                     inline _ConsoleCommandManipulator& popFunction()
     155                    inline ConsoleCommandManipulator& popFunction()
    156156                        { if (this->command_) { this->command_->popFunction(); } return *this; }
    157157
    158                     inline _ConsoleCommandManipulator& resetFunction()
     158                    inline ConsoleCommandManipulator& resetFunction()
    159159                        { if (this->command_) { this->command_->resetFunction(); } return *this; }
    160160
    161                     inline _ConsoleCommandManipulator& setObject(void* object)
     161                    inline ConsoleCommandManipulator& setObject(void* object)
    162162                        { if (this->command_) { this->command_->setObject(object); } return *this; }
    163                     inline _ConsoleCommandManipulator& pushObject(void* object)
     163                    inline ConsoleCommandManipulator& pushObject(void* object)
    164164                        { if (this->command_) { this->command_->pushObject(object); } return *this; }
    165                     inline _ConsoleCommandManipulator& popObject()
     165                    inline ConsoleCommandManipulator& popObject()
    166166                        { if (this->command_) { this->command_->popObject(); } return *this; }
    167167
    168                     inline _ConsoleCommandManipulator& setActive(bool bActive)
     168                    inline ConsoleCommandManipulator& setActive(bool bActive)
    169169                        { if (this->command_) { this->command_->setActive(bActive); } return *this; }
    170                     inline _ConsoleCommandManipulator& activate()
     170                    inline ConsoleCommandManipulator& activate()
    171171                        { return this->setActive(true); }
    172                     inline _ConsoleCommandManipulator& deactivate()
     172                    inline ConsoleCommandManipulator& deactivate()
    173173                        { return this->setActive(false); }
    174174
    175                     inline _ConsoleCommandManipulator& setHidden(bool bHidden)
     175                    inline ConsoleCommandManipulator& setHidden(bool bHidden)
    176176                        { if (this->command_) { this->command_->setHidden(bHidden); } return *this; }
    177                     inline _ConsoleCommandManipulator& hide()
     177                    inline ConsoleCommandManipulator& hide()
    178178                        { return this->setHidden(true); }
    179                     inline _ConsoleCommandManipulator& show()
     179                    inline ConsoleCommandManipulator& show()
    180180                        { return this->setHidden(false); }
    181181
    182                     inline _ConsoleCommandManipulator& defaultValues(const MultiType& param1)
     182                    inline ConsoleCommandManipulator& defaultValues(const MultiType& param1)
    183183                        { if (this->command_) { this->command_->defaultValues(param1); } return *this; }
    184                     inline _ConsoleCommandManipulator& defaultValues(const MultiType& param1, const MultiType& param2)
     184                    inline ConsoleCommandManipulator& defaultValues(const MultiType& param1, const MultiType& param2)
    185185                        { if (this->command_) { this->command_->defaultValues(param1, param2); } return *this; }
    186                     inline _ConsoleCommandManipulator& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3)
     186                    inline ConsoleCommandManipulator& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3)
    187187                        { if (this->command_) { this->command_->defaultValues(param1, param2, param3); } return *this; }
    188                     inline _ConsoleCommandManipulator& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4)
     188                    inline ConsoleCommandManipulator& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4)
    189189                        { if (this->command_) { this->command_->defaultValues(param1, param2, param3, param4); } return *this; }
    190                     inline _ConsoleCommandManipulator& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5)
     190                    inline ConsoleCommandManipulator& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5)
    191191                        { if (this->command_) { this->command_->defaultValues(param1, param2, param3, param4, param5); } return *this; }
    192                     inline _ConsoleCommandManipulator& defaultValue(unsigned int index, const MultiType& param)
     192                    inline ConsoleCommandManipulator& defaultValue(unsigned int index, const MultiType& param)
    193193                        { if (this->command_) { this->command_->defaultValue(index, param); } return *this; }
    194194
    195                     inline _ConsoleCommandManipulator& accessLevel(AccessLevel::Enum level)
     195                    inline ConsoleCommandManipulator& accessLevel(AccessLevel::Enum level)
    196196                        { if (this->command_) { this->command_->accessLevel(level); } return *this; }
    197197
    198                     inline _ConsoleCommandManipulator& argumentCompleter(unsigned int param, ArgumentCompleter* completer)
     198                    inline ConsoleCommandManipulator& argumentCompleter(unsigned int param, ArgumentCompleter* completer)
    199199                        { if (this->command_) { this->command_->argumentCompleter(param, completer); } return *this; }
    200200
    201                     inline _ConsoleCommandManipulator& setAsInputCommand()
     201                    inline ConsoleCommandManipulator& setAsInputCommand()
    202202                        { if (this->command_) { this->command_->setAsInputCommand(); } return *this; }
    203                     inline _ConsoleCommandManipulator& keybindMode(KeybindMode::Value mode)
     203                    inline ConsoleCommandManipulator& keybindMode(KeybindMode::Value mode)
    204204                        { if (this->command_) { this->command_->keybindMode(mode); } return *this; }
    205                     inline _ConsoleCommandManipulator& inputConfiguredParam(int index)
     205                    inline ConsoleCommandManipulator& inputConfiguredParam(int index)
    206206                        { if (this->command_) { this->command_->inputConfiguredParam(index); } return *this; }
    207207
    208208                private:
    209                     _ConsoleCommand* command_;
     209                    ConsoleCommand* command_;
    210210            };
    211211
    212212        public:
    213             _ConsoleCommand(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized = true);
    214             ~_ConsoleCommand();
    215 
    216             _ConsoleCommand& addShortcut();
    217             _ConsoleCommand& addShortcut(const std::string&  name);
    218             _ConsoleCommand& addGroup(const std::string& group);
    219             _ConsoleCommand& addGroup(const std::string& group, const std::string&  name);
     213            ConsoleCommand(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized = true);
     214            ~ConsoleCommand();
     215
     216            ConsoleCommand& addShortcut();
     217            ConsoleCommand& addShortcut(const std::string&  name);
     218            ConsoleCommand& addGroup(const std::string& group);
     219            ConsoleCommand& addGroup(const std::string& group, const std::string&  name);
    220220
    221221            inline const std::string& getName() const
     
    226226                { return this->baseExecutor_; }
    227227
    228             inline _ConsoleCommand& setActive(bool bActive)
     228            inline ConsoleCommand& setActive(bool bActive)
    229229                { this->bActive_ = bActive; return *this; }
    230             inline _ConsoleCommand& activate()
     230            inline ConsoleCommand& activate()
    231231                { return this->setActive(true); }
    232             inline _ConsoleCommand& deactivate()
     232            inline ConsoleCommand& deactivate()
    233233                { return this->setActive(false); }
    234234
    235             inline _ConsoleCommand& setHidden(bool bHidden)
     235            inline ConsoleCommand& setHidden(bool bHidden)
    236236                { this->bHidden_ = bHidden; return *this; }
    237             inline _ConsoleCommand& hide()
     237            inline ConsoleCommand& hide()
    238238                { return this->setHidden(true); }
    239             inline _ConsoleCommand& show()
     239            inline ConsoleCommand& show()
    240240                { return this->setHidden(false); }
    241241
     
    245245                { return this->bHidden_; }
    246246
    247             _ConsoleCommand& description(const std::string& description);
     247            ConsoleCommand& description(const std::string& description);
    248248            const std::string& getDescription() const;
    249249
    250             _ConsoleCommand& descriptionParam(unsigned int param, const std::string& description);
     250            ConsoleCommand& descriptionParam(unsigned int param, const std::string& description);
    251251            const std::string& getDescriptionParam(unsigned int param) const;
    252252
    253             _ConsoleCommand& descriptionReturnvalue(const std::string& description);
     253            ConsoleCommand& descriptionReturnvalue(const std::string& description);
    254254            const std::string& getDescriptionReturnvalue(int param) const;
    255255
    256             _ConsoleCommand& defaultValues(const MultiType& param1);
    257             _ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2);
    258             _ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3);
    259             _ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4);
    260             _ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5);
    261             _ConsoleCommand& defaultValue(unsigned int index, const MultiType& param);
    262 
    263             inline _ConsoleCommand& accessLevel(AccessLevel::Enum level)
     256            ConsoleCommand& defaultValues(const MultiType& param1);
     257            ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2);
     258            ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3);
     259            ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4);
     260            ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5);
     261            ConsoleCommand& defaultValue(unsigned int index, const MultiType& param);
     262
     263            inline ConsoleCommand& accessLevel(AccessLevel::Enum level)
    264264                { this->accessLevel_ = level; return *this; }
    265265            inline AccessLevel::Enum getAccessLevel() const
    266266                { return this->accessLevel_; }
    267267
    268             _ConsoleCommand& argumentCompleter(unsigned int param, ArgumentCompleter* completer);
     268            ConsoleCommand& argumentCompleter(unsigned int param, ArgumentCompleter* completer);
    269269            ArgumentCompleter* getArgumentCompleter(unsigned int param) const;
    270270
    271             inline _ConsoleCommand& setAsInputCommand()
     271            inline ConsoleCommand& setAsInputCommand()
    272272            {
    273273                this->keybindMode(KeybindMode::OnHold);
     
    277277            }
    278278
    279             inline _ConsoleCommand& keybindMode(KeybindMode::Value mode)
     279            inline ConsoleCommand& keybindMode(KeybindMode::Value mode)
    280280                { this->keybindMode_ = mode; return *this; }
    281281            inline KeybindMode::Value getKeybindMode() const
    282282                { return this->keybindMode_; }
    283283
    284             inline _ConsoleCommand& inputConfiguredParam(int index)
     284            inline ConsoleCommand& inputConfiguredParam(int index)
    285285                { this->inputConfiguredParam_ = index; return *this; }
    286286            inline int getInputConfiguredParam_() const
    287287                { return this->inputConfiguredParam_; }
    288288
    289             inline _ConsoleCommandManipulator getManipulator() const
     289            inline ConsoleCommandManipulator getManipulator() const
    290290                { return this; }
    291291
     
    327327
    328328        public:
    329             static inline const std::map<std::string, std::map<std::string, _ConsoleCommand*> >& getCommands()
    330                 { return _ConsoleCommand::getCommandMap(); }
    331             static inline const std::map<std::string, std::map<std::string, _ConsoleCommand*> >& getCommandsLC()
    332                 { return _ConsoleCommand::getCommandMapLC(); }
    333 
    334             static inline _ConsoleCommand* getCommand(const std::string& name, bool bPrintError = false)
    335                 { return _ConsoleCommand::getCommand("", name, bPrintError); }
    336             static inline _ConsoleCommand* getCommandLC(const std::string& name, bool bPrintError = false)
    337                 { return _ConsoleCommand::getCommandLC("", name, bPrintError); }
    338 
    339             static _ConsoleCommand* getCommand(const std::string& group, const std::string& name, bool bPrintError = false);
    340             static _ConsoleCommand* getCommandLC(const std::string& group, const std::string& name, bool bPrintError = false);
     329            static inline const std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommands()
     330                { return ConsoleCommand::getCommandMap(); }
     331            static inline const std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommandsLC()
     332                { return ConsoleCommand::getCommandMapLC(); }
     333
     334            static inline ConsoleCommand* getCommand(const std::string& name, bool bPrintError = false)
     335                { return ConsoleCommand::getCommand("", name, bPrintError); }
     336            static inline ConsoleCommand* getCommandLC(const std::string& name, bool bPrintError = false)
     337                { return ConsoleCommand::getCommandLC("", name, bPrintError); }
     338
     339            static ConsoleCommand* getCommand(const std::string& group, const std::string& name, bool bPrintError = false);
     340            static ConsoleCommand* getCommandLC(const std::string& group, const std::string& name, bool bPrintError = false);
    341341
    342342            static void destroyAll();
    343343
    344344        private:
    345             static std::map<std::string, std::map<std::string, _ConsoleCommand*> >& getCommandMap();
    346             static std::map<std::string, std::map<std::string, _ConsoleCommand*> >& getCommandMapLC();
    347 
    348             static void registerCommand(const std::string& group, const std::string& name, _ConsoleCommand* command);
    349             static void unregisterCommand(_ConsoleCommand* command);
     345            static std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommandMap();
     346            static std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommandMapLC();
     347
     348            static void registerCommand(const std::string& group, const std::string& name, ConsoleCommand* command);
     349            static void unregisterCommand(ConsoleCommand* command);
    350350    };
    351351
    352     inline _ConsoleCommand* _createConsoleCommand(const std::string& name, const ExecutorPtr& executor, bool bInitialized = true)
    353         { return new _ConsoleCommand("", name, executor, bInitialized); }
    354     inline _ConsoleCommand* _createConsoleCommand(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized = true)
    355         { return new _ConsoleCommand(group, name, executor, bInitialized); }
    356 
    357     inline _ConsoleCommand::_ConsoleCommandManipulator _ModifyConsoleCommand(const std::string& name)
    358         { return _ConsoleCommand::getCommand(name, true); }
    359     inline _ConsoleCommand::_ConsoleCommandManipulator _ModifyConsoleCommand(const std::string& group, const std::string& name)
    360         { return _ConsoleCommand::getCommand(group, name, true); }
     352    inline ConsoleCommand* createConsoleCommand(const std::string& name, const ExecutorPtr& executor, bool bInitialized = true)
     353        { return new ConsoleCommand("", name, executor, bInitialized); }
     354    inline ConsoleCommand* createConsoleCommand(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized = true)
     355        { return new ConsoleCommand(group, name, executor, bInitialized); }
     356
     357    inline ConsoleCommand::ConsoleCommandManipulator ModifyConsoleCommand(const std::string& name)
     358        { return ConsoleCommand::getCommand(name, true); }
     359    inline ConsoleCommand::ConsoleCommandManipulator ModifyConsoleCommand(const std::string& group, const std::string& name)
     360        { return ConsoleCommand::getCommand(group, name, true); }
    361361}
    362362
Note: See TracChangeset for help on using the changeset viewer.