Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/towerdefenseHS14/src/libraries/core/EventIncludes.h @ 10233

Last change on this file since 10233 was 8729, checked in by rgrieder, 13 years ago

Merged unity_build branch back to trunk.

Features:

  • Implemented fully automatic build units to speed up compilation if requested
  • Added DOUT macro for quick debug output
  • Activated text colouring in the POSIX IOConsole
  • DeclareToluaInterface is not necessary anymore

Improvements:

  • Output levels now change appropriately when switch back and forth from dev mode
  • Log level for the file output is now also correct during startup
  • Removed some header file dependencies in core and tools to speed up compilation

no more file for command line options

  • Improved util::tribool by adapting some concepts from boost::tribool

Regressions:

  • It is not possible anymore to specify command line arguments in an extra file because we've got config values for that purpose.
  • Property svn:eol-style set to native
File size: 5.1 KB
Line 
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
29/**
30    @file
31    @ingroup Event
32    @brief Definition of the XMLPortEventState() macro, as well as some more useful macros.
33*/
34
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
44/**
45    @brief Defines a new event state (a state of the object which can be changed by events).
46
47    @param classname    The name of this class
48    @param subclassname Usually BaseObject - if different, only instances of this class can send events to this object
49    @param statename    The name (string) of this state
50    @param function     The function which should be used to set the state
51    @param xmlelement   Argument for XMLPort
52    @param mode         Argument for XMLPort
53*/
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
63/**
64    @brief Like XMLPortEventState but creates an event sink instead of an event state.
65           The most important destinction between an EventState and an EventSink is, that an EventState only processes events which change the state of the EventState, where as an EventSink is an EventState that processes any Event that reaches it.
66*/
67
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::ExecutorMemberPtr<classname> xmlsetfunctor##name = orxonox::createExecutor(orxonox::createFunctor(&classname::addEventSource), std::string( #classname ) + "::" + "addEventSource" + '(' + statename + ')').cast<orxonox::ExecutorMember<classname> >(); \
89    static orxonox::ExecutorMemberPtr<classname> xmlgetfunctor##name = orxonox::createExecutor(orxonox::createFunctor(&classname::getEventSource), std::string( #classname ) + "::" + "getEventSource" + '(' + statename + ')').cast<orxonox::ExecutorMember<classname> >(); \
90    xmlsetfunctor##name->setDefaultValue(1, statename); \
91    xmlgetfunctor##name->setDefaultValue(1, statename); \
92    XMLPortObjectGeneric(xmlport##name, classname, orxonox::BaseObject, statename, xmlsetfunctor##name, xmlgetfunctor##name, xmlelement, mode, false, true)
93
94
95/**
96    @brief Defines a new event name for a class. Named events can only have names which were defined with this macro.
97
98    @param classname The name of the class
99    @param name      The name of the event
100*/
101#define CreateEventName(classname, name) \
102    static std::string eventname##classname##name = #name
103
104/**
105    @brief This macro is needed to fire an event with this name. The event name must previously be declared with @ref CreateEventName.
106*/
107#define FireEventName(classname, name) \
108    eventname##classname##name
109
110#endif /* _EventIncludes_H__ */
Note: See TracBrowser for help on using the repository browser.