Orxonox  0.0.5 Codename: Arcturus
Macros
EventIncludes.h File Reference

Definition of the XMLPortEventState() macro, as well as some more useful macros. More...

#include "CorePrereqs.h"
#include "Event.h"
#include "XMLPort.h"
#include "command/Executor.h"

Go to the source code of this file.

Macros

#define CreateEventName(classname, name)   static std::string eventname##classname##name = #name
 Defines a new event name for a class. More...
 
#define FireEventName(classname, name)   eventname##classname##name
 This macro is needed to fire an event with this name. More...
 
#define XMLPortEventSink(classname, subclassname, statename, function, xmlelement, mode)
 Like XMLPortEventState but creates an event sink instead of an event state. More...
 
#define XMLPortEventState(classname, subclassname, statename, function, xmlelement, mode)
 Defines a new event state (a state of the object which can be changed by events). More...
 
#define XMLPortEventStateIntern(name, classname, statename, xmlelement, mode)
 
#define XMLPortEventStateTemplate(classname, subclassname, statename, function, xmlelement, mode, ...)
 

Detailed Description

Definition of the XMLPortEventState() macro, as well as some more useful macros.

Macro Definition Documentation

#define CreateEventName (   classname,
  name 
)    static std::string eventname##classname##name = #name

Defines a new event name for a class.

Named events can only have names which were defined with this macro.

Parameters
classnameThe name of the class
nameThe name of the event
#define FireEventName (   classname,
  name 
)    eventname##classname##name

This macro is needed to fire an event with this name.

The event name must previously be declared with CreateEventName.

#define XMLPortEventSink (   classname,
  subclassname,
  statename,
  function,
  xmlelement,
  mode 
)
Value:
orxonox::EventState* containername##function = this->getEventState(statename); \
if (!containername##function) \
{ \
containername##function = new orxonox::EventState(orxonox::createFunctor(&classname::function, this), orxonox::ClassIdentifier<subclassname>::getIdentifier(), true); \
this->addEventState(statename, containername##function); \
} \
XMLPortEventStateIntern(xmlportevent##function, classname, statename, xmlelement, mode)
The ClassIdentifier is derived from Identifier and holds all class-specific functions and variables t...
Definition: Identifier.h:262
The EventState contains information about an event state.
Definition: Event.h:77
FunctorMemberPtr< O > createFunctor(R(O::*functionPointer)(Params...), OO *object)
Creates a new FunctorMember with the given function-pointer and an assigned object.
Definition: Functor.h:583
xmlelement
Definition: Super.h:519
#define XMLPortEventStateIntern(name, classname, statename, xmlelement, mode)
Definition: EventIncludes.h:87

Like XMLPortEventState but creates an event sink instead of an event state.

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.

#define XMLPortEventState (   classname,
  subclassname,
  statename,
  function,
  xmlelement,
  mode 
)
Value:
orxonox::EventState* containername##function = this->getEventState(statename); \
if (!containername##function) \
{ \
containername##function = new orxonox::EventState(orxonox::createFunctor(&classname::function, this), orxonox::ClassIdentifier<subclassname>::getIdentifier()); \
this->addEventState(statename, containername##function); \
} \
XMLPortEventStateIntern(xmlportevent##function, classname, statename, xmlelement, mode)
The ClassIdentifier is derived from Identifier and holds all class-specific functions and variables t...
Definition: Identifier.h:262
The EventState contains information about an event state.
Definition: Event.h:77
FunctorMemberPtr< O > createFunctor(R(O::*functionPointer)(Params...), OO *object)
Creates a new FunctorMember with the given function-pointer and an assigned object.
Definition: Functor.h:583
xmlelement
Definition: Super.h:519
#define XMLPortEventStateIntern(name, classname, statename, xmlelement, mode)
Definition: EventIncludes.h:87

Defines a new event state (a state of the object which can be changed by events).

Parameters
classnameThe name of this class
subclassnameUsually BaseObject - if different, only instances of this class can send events to this object
statenameThe name (string) of this state
functionThe function which should be used to set the state
xmlelementArgument for XMLPort
modeArgument for XMLPort
#define XMLPortEventStateIntern (   name,
  classname,
  statename,
  xmlelement,
  mode 
)
Value:
static orxonox::ExecutorPtr xmlsetfunctorbase##name = orxonox::createExecutor(orxonox::createFunctor(&classname::addEventSource), std::string( #classname ) + "::" + "addEventSource" + '(' + statename + ')'); \
static orxonox::ExecutorPtr xmlgetfunctorbase##name = orxonox::createExecutor(orxonox::createFunctor(&classname::getEventSource), std::string( #classname ) + "::" + "getEventSource" + '(' + statename + ')'); \
xmlsetfunctor##name->setDefaultValue(1, statename); \
xmlgetfunctor##name->setDefaultValue(1, statename); \
XMLPortObjectGeneric(xmlport##name, classname, orxonox::BaseObject, statename, xmlsetfunctor##name, xmlgetfunctor##name, xmlelement, mode, false, true)
The BaseObject is the parent of all classes representing an instance in the game. ...
Definition: BaseObject.h:63
StrongPtr< T > static_pointer_cast(const StrongPtr< U > &p)
Uses a static_cast to cast a pointer of type U* to a pointer of type T* and returns it in a new Stron...
Definition: StrongPtr.h:291
::std::string string
Definition: gtest-port.h:756
#define XMLPortObjectGeneric(containername, classname, objectclass, sectionname, loadexecutor, saveexecutor, xmlelement, mode, bApplyLoaderMask, bLoadBefore)
Generic XMLPortObject macro, that gets called by all other XMLPortObject macros above.
Definition: XMLPort.h:308
ExecutorPtr createExecutor(const FunctorPtr &functor, const std::string &name="")
Creates a new Executor that wraps a given Functor.
Definition: Executor.h:267
FunctorMemberPtr< O > createFunctor(R(O::*functionPointer)(Params...), OO *object)
Creates a new FunctorMember with the given function-pointer and an assigned object.
Definition: Functor.h:583
xmlelement
Definition: Super.h:519
A child class of Executor, used for easier handling of non-static member-functions.
Definition: Executor.h:212
void setDefaultValue(unsigned int index, const MultiType &arg)
Defines the default value for a parameter with given index (the first parameter has index 0)...
Definition: Executor.cc:204
std::shared_ptr< ExecutorMember< T >> ExecutorMemberPtr
Definition: ExecutorPtr.h:58
std::shared_ptr< Executor > ExecutorPtr
Definition: ExecutorPtr.h:55
#define XMLPortEventStateTemplate (   classname,
  subclassname,
  statename,
  function,
  xmlelement,
  mode,
  ... 
)
Value:
orxonox::EventState* containername##function = this->getEventState(statename); \
if (!containername##function) \
{ \
containername##function = new orxonox::EventState(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::function, this), orxonox::ClassIdentifier<subclassname>::getIdentifier()); \
this->addEventState(statename, containername##function); \
} \
XMLPortEventStateIntern(xmlportevent##function, classname, statename, xmlelement, mode)
The ClassIdentifier is derived from Identifier and holds all class-specific functions and variables t...
Definition: Identifier.h:262
The EventState contains information about an event state.
Definition: Event.h:77
xmlelement
Definition: Super.h:519
#define XMLPortEventStateIntern(name, classname, statename, xmlelement, mode)
Definition: EventIncludes.h:87