Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5641 in orxonox.OLD for trunk/src/lib/util/executor


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/util/executor
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/util/executor/executor.cc

    r5636 r5641  
    3232// SHELL COMMAND BASE //
    3333////////////////////////
     34// empty constructor
     35Executor::Executor()
     36{
     37  this->defaultValue = NULL;
     38}
     39
    3440/**
    3541 * constructs and registers a new Command
     
    6369  delete[] this->defaultValue;
    6470}
     71
     72/**
     73 * clones this element into executor.
     74 */
     75void Executor::cloning(Executor* executor) const
     76{
     77  executor->functorType  = this->functorType;
     78  executor->paramCount   = this->paramCount;
     79  executor->defaultValue = new MultiType[this->paramCount];
     80  for (unsigned int i = 0; i < this->paramCount; i++)
     81    executor->defaultValue[i] = this->defaultValue[i];
     82}
     83
     84
    6585
    6686/**
  • trunk/src/lib/util/executor/executor.h

    r5636 r5641  
    2222typedef enum {
    2323  Executor_Objective   = 1,
    24   Executor_Static    = 2,
     24  Executor_Static      = 2,
    2525} Executor_Type;
    2626
     
    3232{
    3333  public:
     34    virtual ~Executor();
     35
     36    virtual Executor* clone () const = 0;
     37
    3438    Executor* defaultValues(unsigned int count, ...);
    3539    Executor* defaultValues(unsigned int count, va_list values);
     
    3842    virtual void execute (BaseObject* object, const char* parameters) = 0;
    3943
     44    /** @returns the Type of this Function (either static or objective) */
     45    inline Executor_Type getType() const { return this->functorType; };
     46
    4047    static void debug();
    4148
    4249  protected:
     50    Executor();
    4351    Executor(unsigned int paramCount, ...);
    44     ~Executor();
    45 
    46     /** @returns the Type of this Function (either static or objective) */
    47     inline Executor_Type getType() { return this->functorType; };
     52
     53    void cloning(Executor* executor) const;
    4854
    4955  protected:
     
    5157    unsigned int                     paramCount;                           //!< the count of parameters.
    5258    MultiType*                       defaultValue;                         //!< Default Values.
    53 
    54   private:
    5559};
    5660
     
    226230template<class T> class ExecutorObjective : public Executor
    227231{
    228 
    229232  public:
     233    ExecutorObjective() : Executor() { };
     234    // COPY constuctor (virtual version)
     235    virtual Executor* clone () const
     236    {
     237      ExecutorObjective<T>* executor = new ExecutorObjective<T>();
     238      this->cloning(executor);
     239      executor->fp = this->fp;
     240      return executor;
     241    }
     242
    230243//! FUNCTOR_LIST is the List of CommandConstructors
    231244#define FUNCTOR_LIST(x) ExecutorConstructor ## x
     
    279292{
    280293  public:
     294    ExecutorStatic() : Executor() { };
     295    // COPY constuctor
     296    virtual Executor* clone () const
     297    {
     298      ExecutorStatic<T>* executor = new ExecutorStatic<T>();
     299      this->cloning(executor);
     300      executor->fp = this->fp;
     301      return executor;
     302    }
     303
    281304//! FUNCTOR_LIST is the List of CommandConstructors
    282305#define FUNCTOR_LIST(x) ExecutorConstructor ## x
     
    303326};
    304327
    305 //! A Class, that handles aliases.
    306 class ExecutorAlias
    307 {
    308   friend class ExecutorBase;
    309   public:
    310     /** @returns the Name of the Alias. */
    311     const char* getName() const { return this->aliasName; };
    312     /** @returns the Command, this Alias is asociated with */
    313     ExecutorBase* getCommand() const { return this->command; };
    314 
    315   private:
    316     /** @param aliasName the name of the Alias @param command the Command, to associate this alias with */
    317     ExecutorAlias(const char* aliasName, ExecutorBase* command) { this->aliasName = aliasName; this->command = command; };
    318 
    319   private:
    320     const char*         aliasName;       //!< the name of the Alias
    321     ExecutorBase*       command;         //!< a pointer to the command, this alias executes.
    322 };
    323 
    324328#endif /* _EXECUTOR_H */
Note: See TracChangeset for help on using the changeset viewer.