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

#include <message.h>

Public Types

enum  Type : message_t {
  NONE , PING , MOVE_PICK_UP , OPEN ,
  CLOSE , LOCK , UNLOCK , TOGGLE ,
  KILL , TRIGGER , START , STOP ,
  ACTIVATE , ACTIVATE_ONCE , SELECT , SET_PROGRESS ,
  SET_ANIMATION , LAST_MESSAGE
}
 

Static Public Member Functions

static message_t Register (const char *name)
 Registers a new message type. More...
 
static message_t GetType (name_t name)
 Finds a message type from a name. More...
 
static name_t GetName (message_t type)
 Gets a nessage type name. More...
 
static message_t GetLast ()
 
static void Send (const Message &message)
 Sends a message. More...
 
static void Send (const Message &message, float delay)
 Semds a message into the future. More...
 
static void Dispatch ()
 Dispatches sent messsages. More...
 
static void * AllocateData (size_t ammount)
 Allocates space for message data. More...
 
template<typename T >
static T * AllocateData ()
 
template<typename T >
static T * AllocateData (const T &data)
 
static void SetInterceptCallback (void(const Message &))
 

Public Attributes

message_t type
 
id_t sender
 
id_t receiver
 
union {
   void *   data = nullptr
 
   int64_t   data_int
 
   Value *   data_value
 
}; 
 

Member Enumeration Documentation

◆ Type

Enumerator
NONE 
PING 
MOVE_PICK_UP 
OPEN 
CLOSE 
LOCK 
UNLOCK 
TOGGLE 
KILL 
TRIGGER 
START 
STOP 
ACTIVATE 
ACTIVATE_ONCE 
SELECT 
SET_PROGRESS 
SET_ANIMATION 
LAST_MESSAGE 

Member Function Documentation

◆ AllocateData() [1/3]

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

◆ AllocateData() [2/3]

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

◆ AllocateData() [3/3]

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

Allocates space for message data.

This allocation is useful for storing the additional data (Message::data pointer), for messages, since all allocated space will be cleared once all messages have been dispatched. This only applies to messages that are sent without a time delay, if you're sending messages with a delay, then you'll need to allocate memory for their data yourself.

Note
Remember to only use POD data types.

◆ Dispatch()

void tram::Message::Dispatch ( )
static

Dispatches sent messsages.

Dispatches the messages that have been sent using the Message::Send() function.

◆ GetLast()

message_t tram::Message::GetLast ( )
static

◆ GetName()

name_t tram::Message::GetName ( message_t  type)
static

Gets a nessage type name.

◆ GetType()

message_t tram::Message::GetType ( name_t  name)
static

Finds a message type from a name.

◆ Register()

message_t tram::Message::Register ( const char *  name)
static

Registers a new message type.

Returns
Unique message type number.

◆ Send() [1/2]

void tram::Message::Send ( const Message message)
static

Sends a message.

Message will be delivered to the Entity with the ID number specified in the Message::receiver field, by calling its Entity::MessageHandler() method.

◆ Send() [2/2]

void tram::Message::Send ( const Message message,
float  delay 
)
static

Semds a message into the future.

Same as Message::Send(), but the actual sending will be delayed until specified ammount of ticks have passed.

Parameters
messageMessage to be sent.
whenHow many ticks need to pass until the message will be sent out, i.e. if you want to send a message out in 1 secons, set this parameter to 60.

◆ SetInterceptCallback()

void tram::Message::SetInterceptCallback ( void(const Message &)  )
static

Member Data Documentation

◆ 

union { ... } tram::Message::@28

◆ data

void* tram::Message::data = nullptr

◆ data_int

int64_t tram::Message::data_int

◆ data_value

Value* tram::Message::data_value

◆ receiver

id_t tram::Message::receiver

◆ sender

id_t tram::Message::sender

◆ type

message_t tram::Message::type

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