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
//exclude includes when building for MCU
9
#ifndef CCSDS_MCU
10
#include "
CCSDSConfig.h
"
11
#endif
//CCSDS_MCU
12
13
namespace
CCSDS
{
14
class
DataField;
20
class
SecondaryHeaderAbstract
{
21
public
:
22
virtual
~SecondaryHeaderAbstract
() =
default
;
23
28
[[nodiscard]]
virtual
ResultBool
deserialize
(
const
std::vector<std::uint8_t> &data) = 0;
29
30
38
virtual
void
update
(
DataField
* dataField) = 0;
39
44
[[nodiscard]]
virtual
std::uint16_t
getSize
()
const
= 0;
45
50
[[nodiscard]]
virtual
std::vector<std::uint8_t>
serialize
()
const
= 0;
// Pure virtual method for polymorphism
51
56
[[nodiscard]]
virtual
std::string
getType
()
const
= 0;
// Pure virtual method for polymorphism
57
58
#ifndef CCSDS_MCU
59
virtual
ResultBool
loadFromConfig
(
const
Config
&config) = 0;
60
#endif
61
void
setVariableLength
(
const
bool
bEnable){
variableLength
= bEnable;}
62
bool
variableLength
{
false
};
63
};
64
79
class
BufferHeader
final :
public
SecondaryHeaderAbstract
{
80
public
:
81
BufferHeader
() =
default
;
82
86
explicit
BufferHeader
(
const
std::vector<std::uint8_t>& data) :
m_data
(data) {
87
};
88
89
[[nodiscard]]
ResultBool
deserialize
(
const
std::vector<std::uint8_t> &data)
override
{
m_data
= data;
return
true
;};
90
91
[[nodiscard]] std::uint16_t
getSize
()
const override
{
return
m_data
.size(); }
92
[[nodiscard]] std::string
getType
()
const override
{
return
m_type
; }
93
94
[[nodiscard]] std::vector<std::uint8_t>
serialize
()
const override
{
return
m_data
;};
95
void
update
(
DataField
* dataField)
override
{
m_dataLength
=
m_data
.size();}
96
#ifndef CCSDS_MCU
97
ResultBool
loadFromConfig
(
const
Config
&config)
override
{
return
true
;};
98
#endif
99
100
private
:
101
std::vector<std::uint8_t>
m_data
;
102
std::uint16_t
m_dataLength
= 0;
103
const
std::string
m_type
=
"DataOnlyHeader"
;
104
};
105
106
107
}
108
109
110
111
112
#endif
//CCSDS_SECONDARY_HEADER_ABSTRACT_H
CCSDSConfig.h
CCSDSResult.h
CCSDS::BufferHeader
Represents a fixed secondary header used as a data buffer.
Definition
CCSDSSecondaryHeaderAbstract.h:79
CCSDS::BufferHeader::m_data
std::vector< std::uint8_t > m_data
Definition
CCSDSSecondaryHeaderAbstract.h:101
CCSDS::BufferHeader::m_type
const std::string m_type
Definition
CCSDSSecondaryHeaderAbstract.h:103
CCSDS::BufferHeader::getSize
std::uint16_t getSize() const override
Gets the size of the header in bytes.
Definition
CCSDSSecondaryHeaderAbstract.h:91
CCSDS::BufferHeader::update
void update(DataField *dataField) override
Defines how the packet secondary header is updated using the data field as reference.
Definition
CCSDSSecondaryHeaderAbstract.h:95
CCSDS::BufferHeader::m_dataLength
std::uint16_t m_dataLength
Definition
CCSDSSecondaryHeaderAbstract.h:102
CCSDS::BufferHeader::deserialize
ResultBool deserialize(const std::vector< std::uint8_t > &data) override
takes a buffer if data (vector std::uint8) and creates the header
Definition
CCSDSSecondaryHeaderAbstract.h:89
CCSDS::BufferHeader::serialize
std::vector< std::uint8_t > serialize() const override
Retrieves the serialized representation of the header.
Definition
CCSDSSecondaryHeaderAbstract.h:94
CCSDS::BufferHeader::BufferHeader
BufferHeader(const std::vector< std::uint8_t > &data)
Constructs a DataOnlyHeader object with all fields explicitly set.
Definition
CCSDSSecondaryHeaderAbstract.h:86
CCSDS::BufferHeader::getType
std::string getType() const override
Retrieves the name of the packet.
Definition
CCSDSSecondaryHeaderAbstract.h:92
CCSDS::BufferHeader::loadFromConfig
ResultBool loadFromConfig(const Config &config) override
Definition
CCSDSSecondaryHeaderAbstract.h:97
CCSDS::BufferHeader::BufferHeader
BufferHeader()=default
CCSDS::DataField
Represents the data field of a CCSDS packet.
Definition
CCSDSDataField.h:25
CCSDS::Result
Encapsulates a result that can hold either a value or an Error.
Definition
CCSDSResult.h:82
CCSDS::SecondaryHeaderAbstract
Abstract base class for a (Packet Utilization Standard) header.
Definition
CCSDSSecondaryHeaderAbstract.h:20
CCSDS::SecondaryHeaderAbstract::serialize
virtual std::vector< std::uint8_t > serialize() const =0
Retrieves the serialized representation of the header.
CCSDS::SecondaryHeaderAbstract::getType
virtual std::string getType() const =0
Retrieves the name of the packet.
CCSDS::SecondaryHeaderAbstract::~SecondaryHeaderAbstract
virtual ~SecondaryHeaderAbstract()=default
CCSDS::SecondaryHeaderAbstract::update
virtual void update(DataField *dataField)=0
Defines how the packet secondary header is updated using the data field as reference.
CCSDS::SecondaryHeaderAbstract::loadFromConfig
virtual ResultBool loadFromConfig(const Config &config)=0
CCSDS::SecondaryHeaderAbstract::setVariableLength
void setVariableLength(const bool bEnable)
Definition
CCSDSSecondaryHeaderAbstract.h:61
CCSDS::SecondaryHeaderAbstract::variableLength
bool variableLength
Definition
CCSDSSecondaryHeaderAbstract.h:62
CCSDS::SecondaryHeaderAbstract::getSize
virtual std::uint16_t getSize() const =0
Gets the size of the header in bytes.
CCSDS::SecondaryHeaderAbstract::deserialize
virtual ResultBool deserialize(const std::vector< std::uint8_t > &data)=0
takes a buffer if data (vector std::uint8) and creates the header
Config
Parses and stores config values from custom file format.
Definition
CCSDSConfig.h:11
CCSDS
Contains definitions and classes for handling CCSDS headers.
Definition
CCSDSDataField.h:11
Generated by
1.9.8