Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5641 in orxonox.OLD for trunk/src/lib/shell


Ignore:
Timestamp:
Nov 18, 2005, 9:22:23 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: Passing Reference inastead of Pointer to create ShellCommand

Location:
trunk/src/lib/shell
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/shell/shell_command.cc

    r5640 r5641  
    3636 * @param paramCount the count of parameters this command takes
    3737 */
    38 ShellCommand::ShellCommand(const char* commandName, const char* className, Executor* executor)
     38ShellCommand::ShellCommand(const char* commandName, const char* className, const Executor& executor)
    3939{
    4040  this->setClassID(CL_SHELL_COMMAND, "ShellCommand");
     
    5454  this->defaultValue = new MultiType[paramCount];
    5555
    56   this->executor = executor;
     56  this->executor = executor.clone();
    5757}
    5858
     
    6969    delete this->alias;
    7070  }
     71  delete this->executor;
    7172}
    7273
     
    7475 * registers a new ShellCommand
    7576 */
    76 ShellCommand* ShellCommand::registerCommand(const char* commandName, const char* className, Executor* executor)
     77ShellCommand* ShellCommand::registerCommand(const char* commandName, const char* className, const Executor& executor)
    7778{
    7879  if (ShellCommand::isRegistered(commandName, className, executor))
     
    132133 * This is checked in the registerCommand-function.
    133134 */
    134 bool ShellCommand::isRegistered(const char* commandName, const char* className, Executor* executor)
     135bool ShellCommand::isRegistered(const char* commandName, const char* className, const Executor& executor)
    135136{
    136137  if (ShellCommandClass::commandClassList == NULL)
  • trunk/src/lib/shell/shell_command.h

    r5640 r5641  
    4141//        ShellCommand* shell_command_##class##_##command = ShellCommand<class>::registerCommand(#command, #class, &class::function)
    4242#define SHELL_COMMAND(command, class, function) \
    43            ShellCommand* shell_command_##class##_##command = ShellCommand::registerCommand(#command, #class, new ExecutorObjective<class>(&class::function))
     43           ShellCommand* shell_command_##class##_##command = ShellCommand::registerCommand(#command, #class, ExecutorObjective<class>(&class::function))
    4444
    4545/**
     
    5757 */
    5858#define SHELL_COMMAND_STATIC(command, class, function) \
    59            ShellCommand* shell_command_##class##_##command = ShellCommand::registerCommand(#command, #class, new ExecutorStatic<class>(function))
     59           ShellCommand* shell_command_##class##_##command = ShellCommand::registerCommand(#command, #class, ExecutorStatic<class>(function))
    6060
    6161
     
    7272    ShellCommand* defaultValues(unsigned int count, ...);
    7373
    74     static ShellCommand* registerCommand(const char* commandName, const char* className, Executor* executor);
     74    static ShellCommand* registerCommand(const char* commandName, const char* className, const Executor& executor);
    7575
    7676    static void unregisterCommand(const char* commandName, const char* className);
     
    7979
    8080  protected:
    81     ShellCommand(const char* commandName, const char* className, Executor* executor);
     81    ShellCommand(const char* commandName, const char* className, const Executor& executor);
    8282    ~ShellCommand();
    8383
    84     static bool isRegistered(const char* commandName, const char* className, Executor* executor);
     84    static bool isRegistered(const char* commandName, const char* className, const Executor& executor);
    8585    static const char* paramToString(long parameter);
    8686
    8787  protected:
    88     void*                            functionPointer;                      //!< The pointeer to the function of the Class (or static pointer if ClassID == CL_NULL )
    8988    unsigned int                     paramCount;                           //!< the count of parameters.
    9089    unsigned int*                    parameters;                           //!< Parameters the function of this Command takes.
  • trunk/src/lib/shell/shell_command_class.cc

    r5639 r5641  
    217217  {
    218218    ShellCommandClass::commandClassList = new tList<ShellCommandClass>;
    219     ShellCommand::registerCommand("debug", "ShellCommand", new ExecutorStatic<ShellCommand>(ShellCommand::debug));
     219    ShellCommand::registerCommand("debug", "ShellCommand", ExecutorStatic<ShellCommand>(ShellCommand::debug));
    220220  }
    221221}
Note: See TracChangeset for help on using the changeset viewer.