Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/new_class_id/src/lib/util/executor/executor.h @ 9684

Last change on this file since 9684 was 9684, checked in by bensch, 18 years ago

orxonox/branches/new_class_id: slowly but surely reimplementing to the new groove… way to go

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