![]() |
Plasma Engine
2.0
|
Base class for all message types. Each message type has it's own id which is used to dispatch messages efficiently. More...
#include <Message.h>
Public Member Functions | |
virtual plInt32 | GetSortingKey () const |
Derived message types can override this method to influence sorting order. Smaller keys are processed first. | |
PL_ALWAYS_INLINE plMessageId | GetId () const |
Returns the id for this message type. | |
PL_ALWAYS_INLINE plUInt16 | GetSize () const |
Returns the size in byte of this message. | |
PL_ALWAYS_INLINE plUInt64 | GetHash () const |
Calculates a hash of the message. | |
virtual void | Serialize (plStreamWriter &inout_stream) const |
Implement this for efficient transmission across process boundaries (e.g. network transfer etc.) | |
virtual void | Deserialize (plStreamReader &inout_stream, plUInt8 uiTypeVersion) |
![]() | |
virtual const plRTTI * | GetDynamicRTTI () const |
bool | IsInstanceOf (const plRTTI *pType) const |
Returns whether the type of this instance is of the given type or derived from it. | |
template<typename T > | |
PL_ALWAYS_INLINE bool | IsInstanceOf () const |
Returns whether the type of this instance is of the given type or derived from it. | |
Static Public Member Functions | |
static void | PackageForTransfer (const plMessage &msg, plStreamWriter &inout_stream) |
Writes msg to stream in such a way that ReplicatePackedMessage() can restore it even in another process. | |
static plUniquePtr< plMessage > | ReplicatePackedMessage (plStreamReader &inout_stream) |
Restores a message that was written by PackageForTransfer() | |
![]() | |
static const plRTTI * | GetStaticRTTI () |
Protected Member Functions | |
plMessage (size_t messageSize) | |
Static Protected Member Functions | |
static PL_ALWAYS_INLINE plMessageId | GetNextMsgId () |
Protected Attributes | |
plMessageId | m_Id |
plUInt16 | m_uiSize |
Static Protected Attributes | |
static plMessageId | s_NextMsgId = 0 |
Base class for all message types. Each message type has it's own id which is used to dispatch messages efficiently.
To implement a custom message type derive from plMessage and add PL_DECLARE_MESSAGE_TYPE to the type declaration. PL_IMPLEMENT_MESSAGE_TYPE needs to be added to a cpp.
For the automatic cloning to work and for efficiency the messages must only contain simple data members. For instance, everything that allocates internally (strings, arrays) should be avoided. Instead, such objects should be located somewhere else and the message should only contain pointers to the data.
|
inlinevirtual |
Reimplemented in plMsgSetColor, and plMsgSetMeshMaterial.
|
static |
Writes msg to stream in such a way that ReplicatePackedMessage() can restore it even in another process.
For this to work the message type has to have the Serialize and Deserialize functions implemented.
|
static |
Restores a message that was written by PackageForTransfer()
If the message type is unknown, nullptr is returned.
|
inlinevirtual |
Implement this for efficient transmission across process boundaries (e.g. network transfer etc.)
If the message is only ever sent within the same process between nodes of the same plWorld, this does not need to be implemented.
Note that PackageForTransfer() will automatically include the plRTTI type version into the stream and ReplicatePackedMessage() will pass this into Deserialize(). Use this if the serialization changes.
Reimplemented in plMsgSetColor, and plMsgSetMeshMaterial.