Angel 3.2
A 2D Game Prototyping Engine
Public Member Functions | Protected Attributes | List of all members
TypedMessage< T > Class Template Reference

A templated class for delivering additional information with Messages. More...

#include <Message.h>

+ Inheritance diagram for TypedMessage< T >:

Public Member Functions

 TypedMessage (const String &messageName, T value, MessageListener *sender=NULL)
const T GetValue ()
- Public Member Functions inherited from Message
 Message ()
virtual ~Message ()
 Message (const String &messageName, MessageListener *sender=NULL)
virtual const String & GetMessageName () const
MessageListener *const GetSender ()

Protected Attributes

- Protected Attributes inherited from Message
String _messageName

Detailed Description

template<class T>
class TypedMessage< T >

This class lets you define your own message types that carry data with them. For instance, if you wanted to create a Message that carried a world location with it:

TypedMessage<Vector2> *m = new TypedMessage<Vector2>("SomethingHappenedHere", Vector2(-3, -2));

This gets sent through the Switchboard as just a pointer to the base class, though, so your MessageReceivers will have to parse what it is from the Message::GetMessageType function and cast it appropriately from there.

Definition at line 111 of file Message.h.

Constructor & Destructor Documentation

template<class T>
TypedMessage< T >::TypedMessage ( const String &  messageName,
MessageListener sender = NULL 

Creates a new TypedMessage carrying the information you've designated

messageNameThe name of the message
valueAny data of the type defined in the template constructor
senderWho is sending this message; NULL by default

Definition at line 121 of file Message.h.

Member Function Documentation

template<class T>
const T TypedMessage< T >::GetValue ( )

Get the data that this Message carries with it

Data of the type defined in the template constructor

Definition at line 133 of file Message.h.

The documentation for this class was generated from the following file: