summaryrefslogtreecommitdiff
path: root/src/KingSystem/Utils/Thread/Message.cpp
blob: 186f8095b7068b092296f701c53171ad3d073d55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "KingSystem/Utils/Thread/Message.h"

namespace ksys {

Message::Message() = default;

Message::Message(const MesTransceiverId& source, const MesTransceiverId& destination,
                 const MessageType& type, void* user_data, const Message::DelayParams& delay_params,
                 bool ack)
    : mSource(source), mDestination(destination), mType(type), mUserData(user_data),
      mDelayParams(delay_params), mShouldAck(ack) {}

Message::Message(const MesTransceiverId& source, const MessageType& type, void* user_data,
                 const Message::DelayParams& delay_params, bool ack)
    : mSource(source), mType(type), mUserData(user_data), mDelayParams(delay_params),
      mShouldAck(ack) {}

Message::~Message() = default;

const MesTransceiverId& Message::getSource() const {
    return mSource;
}

const MesTransceiverId& Message::getDestination() const {
    return mDestination;
}

const MessageType& Message::getType() const {
    return mType;
}

void* Message::getUserData() const {
    return mUserData;
}

u32 Message::getBrokerId() const {
    return mBrokerId;
}

bool Message::shouldBeProcessed() const {
    if (mDelayParams.delay_ticks != 0)
        return false;

    if (!mDelayParams.delayer)
        return true;

    return mDelayParams.delayer->shouldProcessMessage();
}

bool Message::shouldAck() const {
    return mShouldAck;
}

void Message::setDestination(const MesTransceiverId& dest) {
    mDestination = dest;
}

void Message::setBrokerId(const u32& v) {
    mBrokerId = v;
}

}  // namespace ksys