CCSDSPack
C++ Library for CCSDS Space Packet manipulation. i.e. generation, extraction, analisys and more
Loading...
Searching...
No Matches
CCSDSDataField.h
Go to the documentation of this file.
1#ifndef CCSDS_DATA_FIELD_H
2#define CCSDS_DATA_FIELD_H
3
4#include <CCSDSResult.h>
5#include <cstdint>
6#include <vector>
7#include <memory>
10#include "PusServices.h"
11
12namespace CCSDS {
26 class DataField {
27 public:
29 m_secondaryHeaderFactory.registerType(std::make_shared<BufferHeader>());
30 m_secondaryHeaderFactory.registerType(std::make_shared<PusA>());
31 m_secondaryHeaderFactory.registerType(std::make_shared<PusB>());
32 m_secondaryHeaderFactory.registerType(std::make_shared<PusC>());
33 };
34
35 ~DataField() = default;
36
48 [[nodiscard]] ResultBool setApplicationData(const std::vector<uint8_t> &applicationData);
49
62 [[nodiscard]] ResultBool setApplicationData(const uint8_t *pData, const size_t &sizeData);
63
77 [[nodiscard]] ResultBool setDataFieldHeader(const uint8_t *pData, const size_t &sizeData);
78
94 [[nodiscard]] ResultBool setDataFieldHeader(const uint8_t *pData, const size_t &sizeData,
95 const std::string &pType);
96
111 [[nodiscard]] ResultBool setDataFieldHeader(const std::vector<uint8_t> &data, const std::string &pType);
112
126 [[nodiscard]] ResultBool setDataFieldHeader(const std::vector<uint8_t> &dataFieldHeader);
127
134 void setDataFieldHeader(std::shared_ptr<SecondaryHeaderAbstract> header);
135
142
150
160 void setDataPacketSize(const uint16_t &value);
161
167
177
185 uint16_t getDataFieldUsedBytesSize();
186
195
204 std::vector<uint8_t> getDataFieldHeaderBytes();
205
214 std::vector<uint8_t> getFullDataFieldBytes();
215
223 std::vector<uint8_t> getApplicationData();
224
226 [[nodiscard]] bool getDataFieldHeaderAutoUpdateStatus() const { return m_enableDataFieldUpdate; }
227
233 [[nodiscard]] bool getDataFieldHeaderFlag() const {
234 return m_secondaryHeader != nullptr;
235 }
236
242 [[nodiscard]] std::shared_ptr<SecondaryHeaderAbstract> getSecondaryHeader();
243
252 void update();
253
254 private:
255 std::shared_ptr<SecondaryHeaderAbstract> m_secondaryHeader{};
257 std::vector<uint8_t> m_applicationData{};
258 std::string m_dataFieldHeaderType{};
259 uint16_t m_dataPacketSize{2024};
262
263 };
264}
265
266#endif // CCSDS_DATA_FIELD_H
Represents the data field of a CCSDS packet.
ResultBool setDataFieldHeader(const uint8_t *pData, const size_t &sizeData)
Sets the secondary header data for the data field.
std::shared_ptr< SecondaryHeaderAbstract > m_secondaryHeader
Shared pointer to the secondary header class.
uint16_t getDataFieldAvailableBytesSize()
Retrieves the available size of the data field in bytes.
uint16_t getDataFieldUsedBytesSize()
Retrieves the used size of the data field in bytes.
uint16_t m_dataPacketSize
Data field maximum size in bytes.
std::vector< uint8_t > m_applicationData
Application data buffer.
SecondaryHeaderAbstract & getDataFieldHeader()
returns the secondary header A SecondaryHeaderAbstract derived object containing the header data.
std::vector< uint8_t > getDataFieldHeaderBytes()
Retrieves the secondary header data as a vector of bytes.
std::shared_ptr< SecondaryHeaderAbstract > getSecondaryHeader()
retrieves the known PUS type
bool m_dataFieldHeaderUpdated
Boolean for secondary header updated status.
std::vector< uint8_t > getApplicationData()
Retrieves the application data from the data field.
bool getDataFieldHeaderAutoUpdateStatus() const
returns true if auto update has been enabled for the secondary header
bool getDataFieldHeaderFlag() const
retrieves true if a known secondary header has been set
SecondaryHeaderFactory m_secondaryHeaderFactory
secondary header dispatcher factory
ResultBool setApplicationData(const std::vector< uint8_t > &applicationData)
Sets the application data using a vector of bytes.
std::string m_dataFieldHeaderType
Data field Header type.
void update()
Updates the data field header based on the current application data size.
void setDataFieldHeaderAutoUpdateStatus(const bool enable)
Sets The auto update variable, if disabled the data size in the header field will not be updated.
SecondaryHeaderFactory & getDataFieldHeaderFactory()
returns the secondary header factory
~DataField()=default
void setDataPacketSize(const uint16_t &value)
Sets the maximum data packet size for the CCSDS DataField.
std::vector< uint8_t > getFullDataFieldBytes()
Retrieves the full data field by combining the data field header and application data.
bool m_enableDataFieldUpdate
Boolean for secondary header update enable.
uint16_t getDataFieldAbsoluteBytesSize()
Retrieves the absolute size of the data field in bytes.
Encapsulates a result that can hold either a value or an Error.
Definition CCSDSResult.h:81
Abstract base class for a (Packet Utilization Standard) header.
A singleton factory class responsible for registering and creating instances of SecondaryHeaderAbstra...
void registerType(std::shared_ptr< SecondaryHeaderAbstract > header)
Registers a new header type with its creation function.
Contains definitions and classes for handling CCSDS headers.