Tramway SDK
Public Types | Static Public Member Functions | Public Attributes | List of all members
tram::Event Struct Reference

#include <event.h>

Public Types

enum  Type : event_t {
  KEYPRESS , KEYDOWN , KEYUP , KEYCHAR ,
  CURSORPOS , TICK , SELECTED , LOOK_AT ,
  LAST_EVENT
}
 

Static Public Member Functions

static event_t Register (const char *name)
 Registers a new event type. More...
 
static event_t GetType (name_t name)
 
static name_t GetName (event_t type)
 
static event_t GetLast ()
 
static void Post (const Event &event)
 Adds an event to the event queue. More...
 
static void Dispatch ()
 Dispatches events from the event queue. More...
 
static listener_t AddListener (event_t type, EntityComponent *component)
 Registers a listener. More...
 
static listener_t AddListener (event_t type, Entity *entity)
 Registers a listener. More...
 
static listener_t AddListener (event_t type, void *data, void(*handler)(Event &event, void *data))
 Registers a listener. More...
 
static listener_t AddListener (event_t type, void(*handler)(Event &event))
 Registers a listener. More...
 
static void RemoveListener (listener_t listener_id)
 Deregisters a listener. More...
 
static void * AllocateData (size_t ammount)
 Allocates space for event data. More...
 
template<typename T >
static T * AllocateData ()
 
template<typename T >
static T * AllocateData (const T &data)
 

Public Attributes

event_t type
 
event_t subtype
 
id_t poster_id
 
union {
   void *   data = nullptr
 
   uint64_t   data_int
 
   Value *   data_value
 
}; 
 

Member Enumeration Documentation

◆ Type

Enumerator
KEYPRESS 
KEYDOWN 
KEYUP 
KEYCHAR 
CURSORPOS 
TICK 
SELECTED 
LOOK_AT 
LAST_EVENT 

Member Function Documentation

◆ AddListener() [1/4]

listener_t tram::Event::AddListener ( event_t  type,
Entity entity 
)
static

Registers a listener.

◆ AddListener() [2/4]

listener_t tram::Event::AddListener ( event_t  type,
EntityComponent component 
)
static

Registers a listener.

◆ AddListener() [3/4]

listener_t tram::Event::AddListener ( event_t  type,
void *  data,
void(*)(Event &event, void *data handler 
)
static

Registers a listener.

◆ AddListener() [4/4]

listener_t tram::Event::AddListener ( event_t  type,
void(*)(Event &event)  handler 
)
static

Registers a listener.

◆ AllocateData() [1/3]

template<typename T >
static T * tram::Event::AllocateData ( )
inlinestatic

◆ AllocateData() [2/3]

template<typename T >
static T * tram::Event::AllocateData ( const T &  data)
inlinestatic

◆ AllocateData() [3/3]

void * tram::Event::AllocateData ( size_t  ammount)
static

Allocates space for event data.

This allocation is useful for storing the additional data (Event::data pointer), for events, since all allocated space will be cleared once all events have been dispatched.

Note
Only store POD data types in the allocated memory.

◆ Dispatch()

void tram::Event::Dispatch ( )
static

Dispatches events from the event queue.

◆ GetLast()

event_t tram::Event::GetLast ( )
static

◆ GetName()

name_t tram::Event::GetName ( event_t  type)
static

◆ GetType()

event_t tram::Event::GetType ( name_t  name)
static

◆ Post()

void tram::Event::Post ( const Event event)
static

Adds an event to the event queue.

◆ Register()

event_t tram::Event::Register ( const char *  name)
static

Registers a new event type.

◆ RemoveListener()

void tram::Event::RemoveListener ( listener_t  listener_id)
static

Deregisters a listener.

Member Data Documentation

◆ 

union { ... } tram::Event::@26

◆ data

void* tram::Event::data = nullptr

◆ data_int

uint64_t tram::Event::data_int

◆ data_value

Value* tram::Event::data_value

◆ poster_id

id_t tram::Event::poster_id

◆ subtype

event_t tram::Event::subtype

◆ type

event_t tram::Event::type

The documentation for this struct was generated from the following files: