resonance 1.0.1
Loading...
Searching...
No Matches
message.h
Go to the documentation of this file.
1#pragma once
2
3#include <iostream>
4
5#include "os/mem.h"
6
7class IBStream;
8class OBStream;
9
41class Message {
42public:
55 void *operator new(size_t nSize) {
56 return AllocateTaggedMemory(nSize, "MSG");
57 }
58
68 void operator delete(void *pBlock) {
69 OperatorDeleteOverride(pBlock, "MSG");
70 }
71
82 virtual ~Message();
83
94 virtual Message *Clone() = 0;
95
106 virtual int Type() = 0;
107
116 virtual const char *GetName() const = 0;
117
128 virtual void PrintExtra(std::ostream &stream) const;
129
142 virtual void saveGuts(OBStream &stream) const;
143
158 virtual void restoreGuts(IBStream &stream);
159
171 std::ostream &Print(std::ostream &stream) const;
172
185 static Message *NewMessage(int nType);
186};
Input half of the byte stream interface.
Definition ibstream.h:36
Base of every event the game passes between a MsgSource and a MsgSink.
Definition message.h:41
virtual void PrintExtra(std::ostream &stream) const
Write this message's payload to a stream.
virtual void saveGuts(OBStream &stream) const
Write this message's payload to an output stream.
virtual const char * GetName() const =0
Report this message's class name.
virtual int Type()=0
Report this message's registered identity.
virtual Message * Clone()=0
Produce a heap copy of this message.
virtual void restoreGuts(IBStream &stream)
Read this message's payload from an input stream.
std::ostream & Print(std::ostream &stream) const
Write this message to a diagnostic stream as {GetName() PrintExtra()}.
virtual ~Message()
Vtable slot 1.
static Message * NewMessage(int nType)
Produce a message of the identified class through the factory list.
Output half of the byte stream interface.
Definition obstream.h:25
void OperatorDeleteOverride(void *pBlock, const char *pszClass)
Release a block that AllocateTaggedMemory() handed out.
void * AllocateTaggedMemory(size_t nSize, const char *pszClass)
Allocate a block for one object of a named class.