fsfw/src/fsfw/cfdp/pdu/FileDirectiveReader.h

39 lines
1.3 KiB
C
Raw Normal View History

#ifndef FSFW_SRC_FSFW_CFDP_PDU_FILEDIRECTIVEDESERIALIZER_H_
#define FSFW_SRC_FSFW_CFDP_PDU_FILEDIRECTIVEDESERIALIZER_H_
#include "../definitions.h"
2022-09-08 11:08:40 +02:00
#include "fsfw/cfdp/pdu/PduHeaderReader.h"
/**
* @brief This class is used to deserialize a PDU file directive header from raw memory.
* @details
* Base class for other file directives.
* This is a zero-copy implementation and #parseData needs to be called to ensure the data is
* valid.
*/
2022-09-08 11:08:40 +02:00
class FileDirectiveReader : public PduHeaderReader {
2022-02-02 10:29:30 +01:00
public:
2022-08-03 16:00:48 +02:00
FileDirectiveReader(const uint8_t* pduBuf, size_t maxSize);
2022-02-02 10:29:30 +01:00
/**
* This needs to be called before accessing the PDU fields to avoid segmentation faults.
* @return
*/
2022-08-03 16:00:48 +02:00
ReturnValue_t parseData() override;
[[nodiscard]] size_t getHeaderSize() const override;
2022-09-15 18:41:15 +02:00
[[nodiscard]] cfdp::FileDirective getFileDirective() const;
2022-02-02 10:29:30 +01:00
void setEndianness(SerializeIF::Endianness endianness);
2022-08-03 16:00:48 +02:00
[[nodiscard]] SerializeIF::Endianness getEndianness() const;
static bool checkFileDirective(uint8_t rawByte);
2022-09-08 11:53:06 +02:00
protected:
2022-02-02 10:29:30 +01:00
private:
2022-09-15 18:41:15 +02:00
void setFileDirective(cfdp::FileDirective fileDirective);
cfdp::FileDirective fileDirective = cfdp::FileDirective::INVALID_DIRECTIVE;
2022-02-02 10:29:30 +01:00
SerializeIF::Endianness endianness = SerializeIF::Endianness::NETWORK;
};
#endif /* FSFW_SRC_FSFW_CFDP_PDU_FILEDIRECTIVEDESERIALIZER_H_ */