Orxonox  0.0.5 Codename: Arcturus
EventIncludes.h
Go to the documentation of this file.
1 /*
2  * ORXONOX - the hottest 3D action shooter ever to exist
3  * > www.orxonox.net <
4  *
5  *
6  * License notice:
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  *
22  * Author:
23  * Fabian 'x3n' Landau
24  * Co-authors:
25  * ...
26  *
27  */
28 
35 #ifndef _EventIncludes_H__
36 #define _EventIncludes_H__
37 
38 #include "CorePrereqs.h"
39 
40 #include "Event.h"
41 #include "XMLPort.h"
42 #include "command/Executor.h"
43 
54 #define XMLPortEventState(classname, subclassname, statename, function, xmlelement, mode) \
55  orxonox::EventState* containername##function = this->getEventState(statename); \
56  if (!containername##function) \
57  { \
58  containername##function = new orxonox::EventState(orxonox::createFunctor(&classname::function, this), orxonox::ClassIdentifier<subclassname>::getIdentifier()); \
59  this->addEventState(statename, containername##function); \
60  } \
61  XMLPortEventStateIntern(xmlportevent##function, classname, statename, xmlelement, mode)
62 
68 #define XMLPortEventSink(classname, subclassname, statename, function, xmlelement, mode) \
69  orxonox::EventState* containername##function = this->getEventState(statename); \
70  if (!containername##function) \
71  { \
72  containername##function = new orxonox::EventState(orxonox::createFunctor(&classname::function, this), orxonox::ClassIdentifier<subclassname>::getIdentifier(), true); \
73  this->addEventState(statename, containername##function); \
74  } \
75  XMLPortEventStateIntern(xmlportevent##function, classname, statename, xmlelement, mode)
76 
77 
78 #define XMLPortEventStateTemplate(classname, subclassname, statename, function, xmlelement, mode, ...) \
79  orxonox::EventState* containername##function = this->getEventState(statename); \
80  if (!containername##function) \
81  { \
82  containername##function = new orxonox::EventState(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::function, this), orxonox::ClassIdentifier<subclassname>::getIdentifier()); \
83  this->addEventState(statename, containername##function); \
84  } \
85  XMLPortEventStateIntern(xmlportevent##function, classname, statename, xmlelement, mode)
86 
87 #define XMLPortEventStateIntern(name, classname, statename, xmlelement, mode) \
88  static orxonox::ExecutorPtr xmlsetfunctorbase##name = orxonox::createExecutor(orxonox::createFunctor(&classname::addEventSource), std::string( #classname ) + "::" + "addEventSource" + '(' + statename + ')'); \
89  static orxonox::ExecutorPtr xmlgetfunctorbase##name = orxonox::createExecutor(orxonox::createFunctor(&classname::getEventSource), std::string( #classname ) + "::" + "getEventSource" + '(' + statename + ')'); \
90  static orxonox::ExecutorMemberPtr<classname> xmlsetfunctor##name = std::static_pointer_cast<orxonox::ExecutorMember<classname>>(xmlsetfunctorbase##name); \
91  static orxonox::ExecutorMemberPtr<classname> xmlgetfunctor##name = std::static_pointer_cast<orxonox::ExecutorMember<classname>>(xmlgetfunctorbase##name); \
92  xmlsetfunctor##name->setDefaultValue(1, statename); \
93  xmlgetfunctor##name->setDefaultValue(1, statename); \
94  XMLPortObjectGeneric(xmlport##name, classname, orxonox::BaseObject, statename, xmlsetfunctor##name, xmlgetfunctor##name, xmlelement, mode, false, true)
95 
96 
103 #define CreateEventName(classname, name) \
104  static std::string eventname##classname##name = #name
105 
109 #define FireEventName(classname, name) \
110  eventname##classname##name
111 
112 #endif /* _EventIncludes_H__ */
Shared library macros, enums, constants and forward declarations for the core library ...
Declaration of the XMLPort helper classes and macros.
Declaration of the orxonox::Executor class and the createExecutor() functions.
Declaration of the classes Event and EventState.