Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

big commit, but not much changes in code:

  • put CommandEvaluation into it's own .cc and .h files
  • put some basic ConsoleCommands into ConsoleCommandCompilation.cc and .h
  • created a new class, ConsoleCommand, inheriting from ExecutorStatic, implementing all command-related features that were located in the Executor until now (at the moment only accessLevel_, but more will come - from reto and me)
  • renamed ConsoleCommand-macros to SetConsoleCommand (all related macros were changed the same way)
  • added a new command named "killdelays", that kills all delayed commands. helpful to stop disco ;)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/console/src/core/ConsoleCommand.h

    r1062 r1341  
    3838
    3939
     40#define SetConsoleCommand(classname, function,  bCreateShortcut) \
     41    SetConsoleCommandGeneric(classname##function##consolecommand__, classname, orxonox::createConsoleCommand(orxonox::createFunctor(&classname::function), #function), bCreateShortcut)
    4042
    41 #define ConsoleCommand(classname, function, accesslevel, bCreateShortcut) \
    42     ConsoleCommandGeneric(classname##function##consolecommand__, classname, orxonox::createExecutor(orxonox::createFunctor(&classname::function), #function, accesslevel), bCreateShortcut)
    43 
    44 #define ConsoleCommandGeneric(fakevariable, classname, executor, bCreateShortcut) \
    45     Executor& fakevariable = ClassManager<classname>::getIdentifier()->addConsoleCommand((ExecutorStatic*)executor, bCreateShortcut)
     43#define SetConsoleCommandGeneric(fakevariable, classname, executor, bCreateShortcut) \
     44    Executor& fakevariable = ClassManager<classname>::getIdentifier()->addConsoleCommand((ConsoleCommand*)executor, bCreateShortcut)
    4645
    4746
    48 #define ConsoleCommandShortcut(classname, function, accesslevel) \
    49     ConsoleCommandShortcutGeneric(function##consolecommand__, orxonox::createExecutor(orxonox::createFunctor(&classname::function), #function, accesslevel))
     47#define SetConsoleCommandShortcut(classname, function) \
     48    SetConsoleCommandShortcutGeneric(function##consolecommand__, orxonox::createConsoleCommand(orxonox::createFunctor(&classname::function), #function))
    5049
    51 #define ConsoleCommandShortcutExtern(function, accesslevel) \
    52     ConsoleCommandShortcutGeneric(function##consolecommand__, orxonox::createExecutor(orxonox::createFunctor(&function), #function, accesslevel))
     50#define SetConsoleCommandShortcutExtern(function) \
     51    SetConsoleCommandShortcutGeneric(function##consolecommand__, orxonox::createConsoleCommand(orxonox::createFunctor(&function), #function))
    5352
    54 #define ConsoleCommandShortcutGeneric(fakevariable, executor) \
    55     Executor& fakevariable = CommandExecutor::addConsoleCommandShortcut((ExecutorStatic*)executor)
     53#define SetConsoleCommandShortcutGeneric(fakevariable, executor) \
     54    Executor& fakevariable = CommandExecutor::addConsoleCommandShortcut((ConsoleCommand*)executor)
    5655
    5756
     57namespace orxonox
     58{
     59    namespace AccessLevel
     60    {
     61        enum Level
     62        {
     63            None,
     64            User,
     65            Admin,
     66            Offline,
     67            Debug,
     68            Disabled
     69        };
     70    }
     71
     72    class _CoreExport ConsoleCommand : public ExecutorStatic
     73    {
     74        public:
     75            ConsoleCommand(FunctorStatic* functor, const std::string& name = "") : ExecutorStatic(functor, name), accessLevel_(AccessLevel::None) {}
     76
     77            inline ConsoleCommand& setDescription(const std::string& description)
     78                { this->ExecutorStatic::setDescription(description); return (*this); }
     79            inline ConsoleCommand& setDescriptionParam(int param, const std::string& description)
     80                { this->ExecutorStatic::setDescriptionParam(param, description); return (*this); }
     81            inline ConsoleCommand& setDescriptionReturnvalue(const std::string& description)
     82                { this->ExecutorStatic::setDescriptionReturnvalue(description); return (*this); }
     83            inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1)
     84                { this->ExecutorStatic::setDefaultValues(param1); return (*this); }
     85            inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2)
     86                { this->ExecutorStatic::setDefaultValues(param1, param2); return (*this); }
     87            inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3)
     88                { this->ExecutorStatic::setDefaultValues(param1, param2, param3); return (*this); }
     89            inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4)
     90                { this->ExecutorStatic::setDefaultValues(param1, param2, param3, param4); return (*this); }
     91            inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5)
     92                { this->ExecutorStatic::setDefaultValues(param1, param2, param3, param4, param5); return (*this); }
     93            inline ConsoleCommand& setDefaultValue(unsigned int index, const MultiTypeMath& param)
     94                { this->ExecutorStatic::setDefaultValue(index, param); return (*this); }
     95
     96            inline ConsoleCommand& setAccessLevel(AccessLevel::Level level)
     97                { this->accessLevel_ = level; return (*this); }
     98            inline AccessLevel::Level getAccessLevel() const
     99                { return this->accessLevel_; }
     100
     101        private:
     102            AccessLevel::Level accessLevel_;
     103    };
     104
     105    inline ConsoleCommand* createConsoleCommand(FunctorStatic* functor, const std::string& name = "")
     106    {
     107        return new ConsoleCommand(functor, name);
     108    }
     109}
     110
    58111#endif /* _ConsoleCommand_H__ */
Note: See TracChangeset for help on using the changeset viewer.