Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/core/src/orxonox/core/Executor.h @ 847

Last change on this file since 847 was 847, checked in by landauf, 16 years ago

new loader-concept is taking shape, but not yet finished

added new classes: Functor, Executor and XMLPortParamContainer.
more to come (i.e. XMLPortObjectContainer)

Executor might be useless, depends on how we'll implement the ingame shell-commands and the keybindings

moved all non-identifier-related functions and variables from OrxonoxClass to BaseObject. this might result in some casts to BaseObject when working with all objects of an interface (like Synchronisable), but I think it improves the class hierarchy.

File size: 5.2 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *
4 *
5 *   License notice:
6 *
7 *   This program is free software; you can redistribute it and/or
8 *   modify it under the terms of the GNU General Public License
9 *   as published by the Free Software Foundation; either version 2
10 *   of the License, or (at your option) any later version.
11 *
12 *   This program is distributed in the hope that it will be useful,
13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 *   GNU General Public License for more details.
16 *
17 *   You should have received a copy of the GNU General Public License
18 *   along with this program; if not, write to the Free Software
19 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 *
21 *   Author:
22 *      Fabian 'x3n' Landau
23 *   Co-authors:
24 *      ...
25 *
26 *   Inspiration: Executor by Benjamin Grauer
27 */
28
29#ifndef _Executor_H__
30#define _Executor_H__
31
32#include "CorePrereqs.h"
33#include "Functor.h"
34
35namespace orxonox
36{
37    class _CoreExport Executor
38    {
39        public:
40            Executor(Functor* functor, const std::string& name = "");
41            virtual ~Executor();
42
43            inline virtual void operator()(const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null)
44                { (*this->functor_)(param1, param2, param3, param4, param5); }
45
46            void setName(const std::string name);
47            const std::string& getName() const;
48
49            void description(const std::string& description);
50            const std::string& getDescription() const;
51
52            void descriptionParam(int param, const std::string& description);
53            const std::string& getDescriptionParam(int param) const;
54
55            void descriptionReturnvalue(const std::string& description);
56            const std::string& getDescriptionReturnvalue(int param) const;
57
58            inline int getParamCount() const
59                { return this->functor_->getParamCount(); }
60            inline bool hasReturnvalue() const
61                { return this->functor_->hasReturnvalue(); }
62            inline FunctionType getType() const
63                { return this->functor_->getType(); }
64            inline MultiTypeMath getReturnvalue() const
65                { return this->functor_->getReturnvalue(); }
66            inline std::string getTypenameParam(int param) const
67                { return this->functor_->getTypenameParam(param); }
68            inline std::string getTypenameReturnvalue() const
69                { return this->functor_->getTypenameReturnvalue(); }
70
71        protected:
72            Functor* functor_;
73
74        private:
75            std::string name_;
76
77            LanguageEntryLabel description_;
78            LanguageEntryLabel descriptionReturnvalue_;
79            LanguageEntryLabel descriptionParam_[5];
80
81            bool bAddedDescription_;
82            bool bAddedDescriptionReturnvalue_;
83            bool bAddedDescriptionParam_[5];
84    };
85
86    class _CoreExport ExecutorStatic : public Executor
87    {
88        public:
89            ExecutorStatic(FunctorStatic* functor, const std::string& name = "") : Executor(functor, name) {}
90            virtual ~ExecutorStatic() {}
91
92            inline virtual void operator()(const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null)
93                { (*this->functor_)(param1, param2, param3, param4, param5); }
94    };
95
96    template <class T>
97    class ExecutorMember : public Executor
98    {
99        public:
100            ExecutorMember(FunctorMember<T>* functor, const std::string& name = "") : Executor(functor, name) {}
101            virtual ~ExecutorMember() {}
102
103            inline virtual void operator()(T* object, const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null)
104                { (*this->functor_)(object, param1, param2, param3, param4, param5); }
105            inline virtual void operator()(const T* object, const MultiTypeMath param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null)
106                { (*this->functor_)(object, param1, param2, param3, param4, param5); }
107            inline virtual void operator()(const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null)
108                { (*this->functor_)(param1, param2, param3, param4, param5); }
109
110            inline void setObject(T* object)
111                { this->functor_->setObject(object); }
112            inline void setObject(const T* object)
113                { this->functor_->setObject(object); }
114    };
115}
116
117#endif /* _Executor_H__ */
Note: See TracBrowser for help on using the repository browser.