fsfw/src/fsfw/tmtcpacket/packetmatcher/ApidMatcher.h

37 lines
1.3 KiB
C
Raw Normal View History

2021-06-14 15:14:57 +02:00
#ifndef FSFW_TMTCPACKET_PACKETMATCHER_APIDMATCHER_H_
#define FSFW_TMTCPACKET_PACKETMATCHER_APIDMATCHER_H_
2022-07-19 18:13:25 +02:00
#include "fsfw/globalfunctions/matching/SerializeableMatcherIF.h"
#include "fsfw/serialize/SerializeAdapter.h"
#include "fsfw/tmtcpacket/pus/tm/PusTmIF.h"
#include "fsfw/tmtcpacket/pus/tm/PusTmMinimal.h"
2022-07-19 18:13:25 +02:00
class ApidMatcher : public SerializeableMatcherIF<PusTmIF*> {
2022-02-02 10:29:30 +01:00
private:
uint16_t apid;
public:
2022-07-18 10:20:26 +02:00
explicit ApidMatcher(uint16_t setApid) : apid(setApid) {}
2022-07-19 18:13:25 +02:00
explicit ApidMatcher(PusTmIF* test) : apid(test->getApid()) {}
bool match(PusTmIF* packet) override {
2022-07-18 10:20:26 +02:00
if (packet->getApid() == apid) {
2022-02-02 10:29:30 +01:00
return true;
} else {
return false;
2021-06-14 15:14:57 +02:00
}
2022-02-02 10:29:30 +01:00
}
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
2022-07-18 10:20:26 +02:00
Endianness streamEndianness) const override {
2022-02-02 10:29:30 +01:00
return SerializeAdapter::serialize(&apid, buffer, size, maxSize, streamEndianness);
}
2022-07-18 10:20:26 +02:00
[[nodiscard]] size_t getSerializedSize() const override {
return SerializeAdapter::getSerializedSize(&apid);
}
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
Endianness streamEndianness) override {
2022-02-02 10:29:30 +01:00
return SerializeAdapter::deSerialize(&apid, buffer, size, streamEndianness);
}
};
2022-07-18 10:20:26 +02:00
#endif /* FSFW_TMTCPACKET_PACKETMATCHER_APIDMATCHER_H_ */