Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/util/executor/executor.h @ 9683

Last change on this file since 9683 was 8894, checked in by patrick, 18 years ago

merged the branche single_player_map with the trunk

File size: 3.2 KB
RevLine 
[4838]1/*!
[5632]2 * @file executor.h
[7197]3 * Definition of an Executor
[5391]4 */
[1853]5
[5632]6#ifndef _EXECUTOR_H
7#define _EXECUTOR_H
[1853]8
[5129]9#include "base_object.h"
[1853]10
[5141]11#include "helper_functions.h"
[5552]12#include "multi_type.h"
[5155]13#include "substring.h"
[5635]14#include "functor_list.h" //< MUST BE INCLUDED HERE AT LEAST ONCE.
[5141]15
[5328]16//! an enumerator for the definition of the Type.
17typedef enum {
[7221]18  Executor_Objective         = 1,
19  Executor_Static            = 2,
[5652]20
[7221]21  Executor_NoLoadString      = 8,
[5632]22} Executor_Type;
[5328]23
[5161]24////////////////
25// BASE CLASS //
26////////////////
[7197]27//! a BaseClass for all possible Executors
28/**
29 * An Executor is an Object, that is able to call Objects of Any type (class)
30 * and execute a function with given parameters on it.
31 *
32 * The Executor is able to handle:
33 *  Objects of any Class (Templated)
34 *  Default Values
[8408]35 *  Functions with up to 5 parameters (more seems overhead, split up the function)
[7331]36 *  Functions with many types (@see functor_list.h)
[7197]37 */
[7714]38class Executor : public BaseObject
[5170]39{
[8035]40  public:
41    virtual ~Executor();
[5641]42
[8035]43    virtual Executor* clone () const = 0;
44//    virtual bool operator==(const Executor* executor) const = 0;
[5641]45
[8035]46    // SETTING up the EXECUTOR
47    Executor* defaultValues(const MultiType& value0 = MT_NULL, const MultiType& value1 = MT_NULL,
48                            const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL,
[8894]49                            const MultiType& value4 = MT_NULL, const MultiType& param5 = MT_NULL,
50                            const MultiType& param6 = MT_NULL);
[8035]51    /** @param i the i'th defaultValue, @returns reference to the MultiType */
52    inline MultiType& getDefaultValue(unsigned int i) { return defaultValue[i]; };
[5164]53
[8035]54    // EXECUTE
55    /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
[8271]56    virtual void operator()(BaseObject* object, int& count, void* values) const = 0;
[8035]57    /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes */
58    virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const = 0;
[5161]59
[8035]60    // RETRIEVE INFORMATION
61    /** @returns the Type of this Function (either static or objective) */
62    inline long getType() const { return this->functorType; };
63    /** @returns the Count of Parameters this Executor takes */
64    inline unsigned int getParamCount() const { return this->paramCount; };
[5161]65
[8035]66    static void debug();
[5161]67
[8035]68  protected:
69    Executor(const MultiType& param0 = MT_NULL, const MultiType& param1 = MT_NULL,
70             const MultiType& param2 = MT_NULL, const MultiType& param3 = MT_NULL,
[8894]71             const MultiType& param4 = MT_NULL, const MultiType& param5 = MT_NULL,
72             const MultiType& param6 = MT_NULL);
[5328]73
[8035]74    void cloning(Executor* executor) const;
75
76  protected:
77    short                       functorType;      //!< The type of Function we've got (either static or objective).
78    unsigned int                paramCount;       //!< the count of parameters.
[8894]79    MultiType                   defaultValue[7];  //!< Default Values.
[5161]80};
81
[7722]82#include "executor/executor_functional.h"
[7725]83#define EXECUTOR_FUNCTIONAL_USE_CONST
84#include "executor/executor_functional.h"
[7722]85#define EXECUTOR_FUNCTIONAL_USE_STATIC
86#include "executor/executor_functional.h"
[5161]87
[5632]88#endif /* _EXECUTOR_H */
Note: See TracBrowser for help on using the repository browser.