wavelength 1.0.0
Loading...
Searching...
No Matches
keyboardkeymsg.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4
5#include "msg/message.h"
6#include "os/mem.h"
7#include "os/prnstream.h"
8
15extern int g_nKeyboardKeyMsgType;
16
23class KeyboardKeyMsg : public Message {
24public:
32 explicit KeyboardKeyMsg(int nKey) : mKey(nKey) {
33 }
34
41 void *operator new(size_t nSize) {
42 return PoolMemAlloc(static_cast<int>(nSize), "KeyboardKeyMsg", 0);
43 }
44
50 void operator delete(void *pBlock) {
51 PoolMemFree(pBlock);
52 }
53
61 Message *Clone() override {
62 return new KeyboardKeyMsg(*this);
63 }
64
72 int Type() override {
74 }
75
83 const char *GetName() const override {
84 return "KeyboardKeyMsg";
85 }
86
94 void PrintExtra(PrnStream &stream) const override;
95
97 int GetKey() const {
98 return mKey;
99 }
100
101private:
102 int mKey;
103};
int GetKey() const
Definition keyboardkeymsg.h:97
KeyboardKeyMsg(int nKey)
Construct the message of a key.
Definition keyboardkeymsg.h:32
int Type() override
Report this message's registered identity.
Definition keyboardkeymsg.h:72
void PrintExtra(PrnStream &stream) const override
Write the key.
const char * GetName() const override
Report this message's class name.
Definition keyboardkeymsg.h:83
Message * Clone() override
Produce a heap copy of this message.
Definition keyboardkeymsg.h:61
Base of every event the game passes between a MsgSource and a MsgSink.
Definition message.h:40
Text output stream.
Definition prnstream.h:16
int g_nKeyboardKeyMsgType
Identity that KeyboardKeyMsg::Type() reports.
void * PoolMemAlloc(int nSize, const char *pszTag, int nAlign)
Allocate a block from the pool heaps and bill it to a tag.
void PoolMemFree(void *pBlock)
Return a block PoolMemAlloc() handed out to the pool heap that owns it.