BWAPI
Classes | Defines
SPAR/AIModule/SparAIModule/Utils/EventHandler.h File Reference
#include "../../Utils/Utils.h"
#include <utility>
#include <boost/tuple/tuple.hpp>
Include dependency graph for EventHandler.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  EventHandlerBase
 Base class for event handlers, which are receptors that listen to and handle events. The virtual destructor is necessary only so that this class is virtual. More...
struct  EventHandlerT< Arguments >
 Base class for event handlers, templated on the type of arguments sent with the particular events. More...
struct  EventHandler
 Shorthand for event handlers with no argument. More...
struct  EventHandler1< T1 >
 Shorthand for event handlers with one argument. More...
struct  EventHandler2< T1, T2 >
 Shorthand for event handlers with two arguments. More...
struct  EventHandler3< T1, T2, T3 >
 Shorthand for event handlers with three arguments. More...
struct  EventHandler4< T1, T2, T3, T4 >
 Shorthand for event handlers with four arguments. More...
struct  EventHandler5< T1, T2, T3, T4, T5 >
 Shorthand for event handlers with five arguments. More...

Defines

#define EVENT_HANDLER_NAME(Type, Function)   EventHandler_##Type##_##Function
#define EVENT_HANDLER(Type, Function)
#define EVENT_HANDLER1(Type, Function, T1)
#define EVENT_HANDLER2(Type, Function, T1, T2)
#define EVENT_HANDLER3(Type, Function, T1, T2, T3)
#define EVENT_HANDLER4(Type, Function, T1, T2, T3, T4)
#define EVENT_HANDLER5(Type, Function, T1, T2, T3, T4, T5)

Define Documentation

#define EVENT_HANDLER (   Type,
  Function 
)
Value:
struct EVENT_HANDLER_NAME(Type, Function) : EventHandler \
  { \
    EVENT_HANDLER_NAME(Type, Function)(Type& object) \
      : EventHandler(object) \
      , m_object(object) {} \
    virtual ~EVENT_HANDLER_NAME(Type, Function)() {} \
    virtual void onEvent(void* data, arguments&) \
    { \
      m_object.Function(data); \
    } \
  private: \
    Type& m_object; \
  }
#define EVENT_HANDLER1 (   Type,
  Function,
  T1 
)
Value:
struct EVENT_HANDLER_NAME(Type, Function) : EventHandler1<T1> \
  { \
    EVENT_HANDLER_NAME(Type, Function)(Type& object) \
      : EventHandler1(object) \
      , m_object(object) {} \
    virtual ~EVENT_HANDLER_NAME(Type, Function)() {} \
    virtual void onEvent(void* data, arguments& args) \
    { \
      m_object.Function(data, args.get<0>()); \
    } \
  private: \
    Type& m_object; \
  }
#define EVENT_HANDLER2 (   Type,
  Function,
  T1,
  T2 
)
Value:
struct EVENT_HANDLER_NAME(Type, Function) : EventHandler2<T1,T2> \
  { \
    EVENT_HANDLER_NAME(Type, Function)(Type& object) \
      : EventHandler2(object) \
      , m_object(object) {} \
    virtual ~EVENT_HANDLER_NAME(Type, Function)() {} \
    virtual void onEvent(void* data, arguments& args) \
    { \
      m_object.Function(data, args.get<0>(), args.get<1>()); \
    } \
  private: \
    Type& m_object; \
  }
#define EVENT_HANDLER3 (   Type,
  Function,
  T1,
  T2,
  T3 
)
Value:
struct EVENT_HANDLER_NAME(Type, Function) : EventHandler3<T1,T2,T3> \
  { \
    EVENT_HANDLER_NAME(Type, Function)(Type& object) \
      : EventHandler3(object) \
      , m_object(object) {} \
    virtual ~EVENT_HANDLER_NAME(Type, Function)() {} \
    virtual void onEvent(void* data, arguments& args) \
    { \
      m_object.Function(data, args.get<0>(), args.get<1>(), args.get<2>()); \
    } \
  private: \
    Type& m_object; \
  }
#define EVENT_HANDLER4 (   Type,
  Function,
  T1,
  T2,
  T3,
  T4 
)
Value:
struct EVENT_HANDLER_NAME(Type, Function) : EventHandler4<T1,T2,T3,T4> \
  { \
    EVENT_HANDLER_NAME(Type, Function)(Type& object) \
      : EventHandler4(object) \
      , m_object(object) {} \
    virtual ~EVENT_HANDLER_NAME(Type, Function)() {} \
    virtual void onEvent(void* data, arguments& args) \
    { \
      m_object.Function(data, args.get<0>(), args.get<1>(), args.get<2>(), args.get<3>()); \
    } \
  private: \
    Type& m_object; \
  }
#define EVENT_HANDLER5 (   Type,
  Function,
  T1,
  T2,
  T3,
  T4,
  T5 
)
Value:
struct EVENT_HANDLER_NAME(Type, Function) : EventHandler5<T1,T2,T3,T4,T5> \
  { \
    EVENT_HANDLER_NAME(Type, Function)(Type& object) \
      : EventHandler5(object) \
      , m_object(object) {} \
    virtual ~EVENT_HANDLER_NAME(Type, Function)() {} \
    virtual void onEvent(void* data, arguments& args) \
    { \
      m_object.Function(data, args.get<0>(), args.get<1>(), args.get<2>(), args.get<3>(), args.get<4>()); \
    } \
  private: \
    Type& m_object; \
  }
#define EVENT_HANDLER_NAME (   Type,
  Function 
)    EventHandler_##Type##_##Function
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines