wavelength 1.0.0
Loading...
Searching...
No Matches
btnevent.h
Go to the documentation of this file.
1#pragma once
2
3#include "os/binstream.h"
4
14template <int kId>
15class BtnEvent {
16public:
18 BtnEvent() = default;
19
25 explicit BtnEvent(BinStream &stream) {
26 Load(stream);
27 }
28
34 void Save(BinStream &stream) const {
35 const unsigned char nPlayer = mPlayer;
36 stream.Write(&nPlayer, sizeof(nPlayer));
37 }
38
44 void Load(BinStream &stream) {
45 stream.Read(&mPlayer, sizeof(mPlayer));
46 }
47
49 unsigned char GetPlayer() const {
50 return mPlayer;
51 }
52
54 void SetPlayer(unsigned char nPlayer) {
55 mPlayer = nPlayer;
56 }
57
58private:
59 unsigned char mPlayer;
60};
Stream of raw bytes, the base of the memory, file, and network streams.
Definition binstream.h:22
virtual void Read(void *pData, int nBytes)=0
Read bytes.
virtual void Write(const void *pData, int nBytes)=0
Write bytes.
void Load(BinStream &stream)
Read the event Save() records.
Definition btnevent.h:44
void SetPlayer(unsigned char nPlayer)
Definition btnevent.h:54
BtnEvent(BinStream &stream)
Construct the event from a recording.
Definition btnevent.h:25
void Save(BinStream &stream) const
Record the player in one byte.
Definition btnevent.h:34
BtnEvent()=default
Construct an event with an unset player.
unsigned char GetPlayer() const
Definition btnevent.h:49