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
// Copyright 2025-2026 ExoSpaceLabs
2
// SPDX-License-Identifier: Apache-2.0
3
4
#ifndef CCSDS_SECONDARY_HEADER_ABSTRACT_H
5
#define CCSDS_SECONDARY_HEADER_ABSTRACT_H
6
7
#include <
CCSDSResult.h
>
8
#include <vector>
9
#include <cstdint>
10
11
//exclude includes when building for MCU
12
#ifndef CCSDS_MCU
13
#include "
CCSDSConfig.h
"
14
#endif
//CCSDS_MCU
15
16
namespace
CCSDS
{
17
class
DataField;
23
class
SecondaryHeaderAbstract
{
24
public
:
25
virtual
~SecondaryHeaderAbstract
() =
default
;
26
31
[[nodiscard]]
virtual
ResultBool
deserialize
(
const
std::vector<std::uint8_t> &data) = 0;
32
33
41
virtual
void
update
(
DataField
* dataField) = 0;
42
47
[[nodiscard]]
virtual
std::uint16_t
getSize
()
const
= 0;
48
53
[[nodiscard]]
virtual
std::vector<std::uint8_t>
serialize
()
const
= 0;
// Pure virtual method for polymorphism
54
59
[[nodiscard]]
virtual
std::string
getType
()
const
= 0;
// Pure virtual method for polymorphism
60
61
#ifndef CCSDS_MCU
62
virtual
ResultBool
loadFromConfig
(
const
Config
&config) = 0;
63
#endif
64
void
setVariableLength
(
const
bool
bEnable){
variableLength
= bEnable;}
65
bool
variableLength
{
false
};
66
};
67
82
class
BufferHeader
final :
public
SecondaryHeaderAbstract
{
83
public
:
84
BufferHeader
() =
default
;
85
89
explicit
BufferHeader
(
const
std::vector<std::uint8_t>& data) :
m_data
(data) {
90
};
91
92
[[nodiscard]]
ResultBool
deserialize
(
const
std::vector<std::uint8_t> &data)
override
{
m_data
= data;
return
true
;};
93
94
[[nodiscard]] std::uint16_t
getSize
()
const override
{
return
m_data
.size(); }
95
[[nodiscard]] std::string
getType
()
const override
{
return
m_type
; }
96
97
[[nodiscard]] std::vector<std::uint8_t>
serialize
()
const override
{
return
m_data
;};
98
void
update
(
DataField
* dataField)
override
{
m_dataLength
=
m_data
.size();}
99
#ifndef CCSDS_MCU
100
ResultBool
loadFromConfig
(
const
Config
&config)
override
{
return
true
;};
101
#endif
102
103
private
:
104
std::vector<std::uint8_t>
m_data
;
105
std::uint16_t
m_dataLength
= 0;
106
const
std::string
m_type
=
"DataOnlyHeader"
;
107
};
108
109
110
}
111
112
113
114
115
#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:82
CCSDS::BufferHeader::m_data
std::vector< std::uint8_t > m_data
Definition
CCSDSSecondaryHeaderAbstract.h:104
CCSDS::BufferHeader::m_type
const std::string m_type
Definition
CCSDSSecondaryHeaderAbstract.h:106
CCSDS::BufferHeader::getSize
std::uint16_t getSize() const override
Gets the size of the header in bytes.
Definition
CCSDSSecondaryHeaderAbstract.h:94
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:98
CCSDS::BufferHeader::m_dataLength
std::uint16_t m_dataLength
Definition
CCSDSSecondaryHeaderAbstract.h:105
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:92
CCSDS::BufferHeader::serialize
std::vector< std::uint8_t > serialize() const override
Retrieves the serialized representation of the header.
Definition
CCSDSSecondaryHeaderAbstract.h:97
CCSDS::BufferHeader::BufferHeader
BufferHeader(const std::vector< std::uint8_t > &data)
Constructs a DataOnlyHeader object with all fields explicitly set.
Definition
CCSDSSecondaryHeaderAbstract.h:89
CCSDS::BufferHeader::getType
std::string getType() const override
Retrieves the name of the packet.
Definition
CCSDSSecondaryHeaderAbstract.h:95
CCSDS::BufferHeader::loadFromConfig
ResultBool loadFromConfig(const Config &config) override
Definition
CCSDSSecondaryHeaderAbstract.h:100
CCSDS::BufferHeader::BufferHeader
BufferHeader()=default
CCSDS::DataField
Represents the data field of a CCSDS packet.
Definition
CCSDSDataField.h:28
CCSDS::Result
Encapsulates a result that can hold either a value or an Error.
Definition
CCSDSResult.h:85
CCSDS::SecondaryHeaderAbstract
Abstract base class for a (Packet Utilization Standard) header.
Definition
CCSDSSecondaryHeaderAbstract.h:23
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:64
CCSDS::SecondaryHeaderAbstract::variableLength
bool variableLength
Definition
CCSDSSecondaryHeaderAbstract.h:65
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:14
CCSDS
Contains definitions and classes for handling CCSDS headers.
Definition
CCSDSDataField.h:14
Generated by
1.9.8