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

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

#include <Message.h>

+ Inheritance diagram for TypedMessage< T >:

List of all members.

Public Member Functions

 TypedMessage (const String &messageName, T value, MessageListener *sender=NULL)
const T GetValue ()

Protected Attributes

_value

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 106 of file Message.h.


Constructor & Destructor Documentation

template<class T>
TypedMessage< T >::TypedMessage ( const String &  messageName,
value,
MessageListener sender = NULL 
) [inline]

Creates a new TypedMessage carrying the information you've designated

Parameters:
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 116 of file Message.h.


Member Function Documentation

template<class T>
const T TypedMessage< T >::GetValue ( ) [inline]

Get the data that this Message carries with it

Returns:
Data of the type defined in the template constructor

Definition at line 128 of file Message.h.


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