CCSDSPack
C++ Library for CCSDS Space Packet manipulation. i.e. generation, extraction, analisys and more
Loading...
Searching...
No Matches
inc
CCSDSSecondaryHeaderAbstract.h
Go to the documentation of this file.
1
#ifndef CCSDS_SECONDARY_HEADER_ABSTRACT_H
2
#define CCSDS_SECONDARY_HEADER_ABSTRACT_H
3
4
#include <
CCSDSResult.h
>
5
#include <vector>
6
#include <cstdint>
7
8
namespace
CCSDS
{
14
class
SecondaryHeaderAbstract
{
15
public
:
16
virtual
~SecondaryHeaderAbstract
() =
default
;
17
22
virtual
void
setDataLength
(uint16_t dataLength) = 0;
23
24
29
[[nodiscard]]
virtual
ResultBool
deserialize
(
const
std::vector<uint8_t> &data) = 0;
30
35
[[nodiscard]]
virtual
uint16_t
getDataLength
()
const
= 0;
36
41
[[nodiscard]]
virtual
uint16_t
getSize
()
const
= 0;
42
47
[[nodiscard]]
virtual
std::vector<uint8_t>
serialize
()
const
= 0;
// Pure virtual method for polymorphism
48
53
[[nodiscard]]
virtual
std::string
getType
()
const
= 0;
// Pure virtual method for polymorphism
54
};
55
70
class
BufferHeader
final :
public
SecondaryHeaderAbstract
{
71
public
:
72
BufferHeader
() =
default
;
73
77
explicit
BufferHeader
(
const
std::vector<uint8_t>& data) :
m_data
(data) {
78
};
79
80
void
setDataLength
(
const
uint16_t dataLength)
override
{
m_dataLength
= dataLength; }
81
82
[[nodiscard]]
ResultBool
deserialize
(
const
std::vector<uint8_t> &data)
override
{
m_data
= data;
return
true
;};
83
84
[[nodiscard]] uint16_t
getDataLength
()
const override
{
return
m_dataLength
; }
85
[[nodiscard]] uint16_t
getSize
()
const override
{
return
m_data
.size(); }
86
[[nodiscard]] std::string
getType
()
const override
{
return
m_type
; }
87
88
[[nodiscard]] std::vector<uint8_t>
serialize
()
const override
{
return
m_data
;};
89
90
private
:
91
std::vector<uint8_t>
m_data
;
92
uint16_t
m_dataLength
= 0;
93
const
std::string
m_type
=
"DataOnlyHeader"
;
94
};
95
96
97
}
98
99
100
101
102
#endif
//CCSDS_SECONDARY_HEADER_ABSTRACT_H
CCSDSResult.h
CCSDS::BufferHeader
Represents a fixed secondary header used as a data buffer.
Definition
CCSDSSecondaryHeaderAbstract.h:70
CCSDS::BufferHeader::deserialize
ResultBool deserialize(const std::vector< uint8_t > &data) override
takes a buffer if data (vector uint8) and creates the header
Definition
CCSDSSecondaryHeaderAbstract.h:82
CCSDS::BufferHeader::serialize
std::vector< uint8_t > serialize() const override
Retrieves the serialized representation of the header.
Definition
CCSDSSecondaryHeaderAbstract.h:88
CCSDS::BufferHeader::m_type
const std::string m_type
Definition
CCSDSSecondaryHeaderAbstract.h:93
CCSDS::BufferHeader::BufferHeader
BufferHeader(const std::vector< uint8_t > &data)
Constructs a DataOnlyHeader object with all fields explicitly set.
Definition
CCSDSSecondaryHeaderAbstract.h:77
CCSDS::BufferHeader::setDataLength
void setDataLength(const uint16_t dataLength) override
Sets the length of the data associated with the packet.
Definition
CCSDSSecondaryHeaderAbstract.h:80
CCSDS::BufferHeader::getType
std::string getType() const override
Retrieves the name of the packet.
Definition
CCSDSSecondaryHeaderAbstract.h:86
CCSDS::BufferHeader::BufferHeader
BufferHeader()=default
CCSDS::BufferHeader::m_dataLength
uint16_t m_dataLength
Definition
CCSDSSecondaryHeaderAbstract.h:92
CCSDS::BufferHeader::m_data
std::vector< uint8_t > m_data
Definition
CCSDSSecondaryHeaderAbstract.h:91
CCSDS::BufferHeader::getDataLength
uint16_t getDataLength() const override
Gets the length of the data associated with the packet if applicable.
Definition
CCSDSSecondaryHeaderAbstract.h:84
CCSDS::BufferHeader::getSize
uint16_t getSize() const override
Gets the size of the header in bytes.
Definition
CCSDSSecondaryHeaderAbstract.h:85
CCSDS::Result
Encapsulates a result that can hold either a value or an Error.
Definition
CCSDSResult.h:81
CCSDS::SecondaryHeaderAbstract
Abstract base class for a (Packet Utilization Standard) header.
Definition
CCSDSSecondaryHeaderAbstract.h:14
CCSDS::SecondaryHeaderAbstract::getType
virtual std::string getType() const =0
Retrieves the name of the packet.
CCSDS::SecondaryHeaderAbstract::~SecondaryHeaderAbstract
virtual ~SecondaryHeaderAbstract()=default
CCSDS::SecondaryHeaderAbstract::getSize
virtual uint16_t getSize() const =0
Gets the size of the header in bytes.
CCSDS::SecondaryHeaderAbstract::getDataLength
virtual uint16_t getDataLength() const =0
Gets the length of the data associated with the packet if applicable.
CCSDS::SecondaryHeaderAbstract::deserialize
virtual ResultBool deserialize(const std::vector< uint8_t > &data)=0
takes a buffer if data (vector uint8) and creates the header
CCSDS::SecondaryHeaderAbstract::serialize
virtual std::vector< uint8_t > serialize() const =0
Retrieves the serialized representation of the header.
CCSDS::SecondaryHeaderAbstract::setDataLength
virtual void setDataLength(uint16_t dataLength)=0
Sets the length of the data associated with the packet.
CCSDS
Contains definitions and classes for handling CCSDS headers.
Definition
CCSDSDataField.h:12
Generated by
1.9.8