F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
DpContainer.hpp
Go to the documentation of this file.
1// ======================================================================
2// \title DpContainer.hpp
3// \author bocchino
4// \brief hpp file for DpContainer
5// ======================================================================
6
7#ifndef Fw_DpContainer_HPP
8#define Fw_DpContainer_HPP
9
10#include "Fw/Buffer/Buffer.hpp"
12#include "Fw/Time/Time.hpp"
14#include "Utils/Hash/Hash.hpp"
17
18namespace Fw {
19
22 public:
23 // ----------------------------------------------------------------------
24 // Constants and Types
25 // ----------------------------------------------------------------------
26
50
59
60 public:
61 // ----------------------------------------------------------------------
62 // Constructors and destructors
63 // ----------------------------------------------------------------------
64
67 const Fw::Buffer& buffer
68 );
69
72
74 virtual ~DpContainer() {}
75
76 protected:
77 // ----------------------------------------------------------------------
78 // Protected operators
79 // ----------------------------------------------------------------------
80
82 DpContainer& operator=(const DpContainer& src) = default;
83
84 public:
85 // ----------------------------------------------------------------------
86 // Public member functions
87 // ----------------------------------------------------------------------
88
91 FwDpIdType getId() const { return this->m_id; }
92
95 FwSizeType getDataSize() const { return this->m_dataSize; }
96
99 Fw::Buffer getBuffer() const { return this->m_buffer; }
100
103
106 FwDpPriorityType getPriority() const { return this->m_priority; }
107
110 Fw::Time getTimeTag() const { return this->m_timeTag; }
111
113 Fw::DpState getState() const { return this->m_dpState; }
114
118
120 DpState getDpState() const { return this->m_dpState; }
121
128
131 void serializeHeader();
132
135 ) {
136 this->m_id = id;
137 }
138
141 ) {
142 this->m_priority = priority;
143 }
144
146 void setTimeTag(Fw::Time timeTag
147 ) {
148 this->m_timeTag = timeTag;
149 }
150
153 ) {
154 this->m_procTypes = procTypes;
155 }
156
158 void setDpState(DpState dpState
159 ) {
160 this->m_dpState = dpState;
161 }
162
164 void setDataSize(FwSizeType dataSize
165 ) {
166 this->m_dataSize = dataSize;
167 }
168
170 void setBuffer(const Buffer& buffer
171 );
172
175 this->m_buffer = Fw::Buffer();
176 this->m_dataBuffer.clear();
177 this->m_dataSize = 0;
178 }
179
183
187
189 void setHeaderHash(const Utils::HashBuffer& hash
190 );
191
193 void updateHeaderHash();
194
197 Utils::HashBuffer& computedHash
198 ) const;
199
202 // Data hash goes after the header, the header hash, and the data
204 }
205
209
213
216 );
217
219 void updateDataHash();
220
223 Utils::HashBuffer& computedHash
224 ) const;
225
226 public:
227 // ----------------------------------------------------------------------
228 // Public static functions
229 // ----------------------------------------------------------------------
230
233 ) {
234 return Header::SIZE + dataSize + 2 * HASH_DIGEST_LENGTH;
235 }
236
237 PRIVATE:
238 // ----------------------------------------------------------------------
239 // Private member functions
240 // ----------------------------------------------------------------------
241
243 void initUserDataField();
244
245 public:
246 // ----------------------------------------------------------------------
247 // Public member variables
248 // ----------------------------------------------------------------------
249
252
253 PROTECTED:
254 // ----------------------------------------------------------------------
255 // Protected member variables
256 // ----------------------------------------------------------------------
257
261
264
267
270
273
276
279
284};
285
286} // end namespace Fw
287
288#endif
uint8_t U8
8-bit unsigned integer
Definition BasicTypes.h:30
#define HASH_DIGEST_LENGTH
Definition CRC32.hpp:18
U32 FwDpPriorityType
Definition FpConfig.h:119
U32 FwDpIdType
Definition FpConfig.h:115
U16 FwSizeStoreType
Definition FpConfig.h:59
U32 FwPacketDescriptorType
Definition FpConfig.h:87
PlatformSizeType FwSizeType
Definition FpConfig.h:35
U8 SerialType
The serial representation type.
A data product Container.
DpCfg::ProcType::SerialType m_procTypes
The processing types.
void setPriority(FwDpPriorityType priority)
Set the priority.
Fw::Time getTimeTag() const
static constexpr FwSizeType DATA_OFFSET
The data offset.
DpContainer()
Constructor for container with default initialization.
DpCfg::ProcType::SerialType getProcTypes() const
Utils::HashBuffer getDataHash() const
FwDpPriorityType m_priority
The priority.
Header::UserData m_userData
The user data.
FwDpIdType getId() const
DpContainer & operator=(const DpContainer &src)=default
Copy assignment operator.
void setId(FwDpIdType id)
Set the id.
static constexpr FwSizeType MIN_PACKET_SIZE
void updateHeaderHash()
Compute and set the header hash.
void setTimeTag(Fw::Time timeTag)
Set the time tag.
void invalidateBuffer()
Invalidate the packet buffer.
void setDpState(DpState dpState)
Set the data product state.
FwDpPriorityType getPriority() const
Utils::HashBuffer computeDataHash() const
Utils::HashBuffer computeHeaderHash() const
Fw::Buffer getBuffer() const
Fw::DpState getState() const
Get the product state.
Fw::SerializeStatus deserializeHeader()
Utils::HashBuffer getHeaderHash() const
virtual ~DpContainer()
Destructor.
Fw::ExternalSerializeBufferWithMemberCopy m_dataBuffer
DpState getDpState() const
Get the data product state.
Time m_timeTag
The time tag.
Success::T checkHeaderHash(Utils::HashBuffer &storedHash, Utils::HashBuffer &computedHash) const
Check the header hash.
static constexpr FwSizeType getPacketSizeForDataSize(FwSizeType dataSize)
Get the packet size for a given data size.
FwSizeType getPacketSize() const
Get the packet size corresponding to the data size.
void setDataHash(Utils::HashBuffer hash)
Set the data hash.
Buffer m_buffer
The packet buffer.
FwSizeType m_dataSize
The data size.
FwSizeType getDataSize() const
void setBuffer(const Buffer &buffer)
Set the packet buffer.
void setHeaderHash(const Utils::HashBuffer &hash)
Set the header hash.
FwSizeType getDataHashOffset() const
Get the data hash offset.
static constexpr FwSizeType HEADER_HASH_OFFSET
The header hash offset.
void setDataSize(FwSizeType dataSize)
Set the data size.
Success::T checkDataHash(Utils::HashBuffer &storedHash, Utils::HashBuffer &computedHash) const
Check the data hash.
void updateDataHash()
Update the data hash.
DpState m_dpState
The data product state.
void setProcTypes(DpCfg::ProcType::SerialType procTypes)
Set the processing types bit mask.
@ SERIALIZED_SIZE
The size of the serial representation.
void clear()
clear external buffer
T
The raw enum type.
@ SERIALIZED_SIZE
Definition Time.hpp:13
A container class for holding a hash buffer.
SerializeStatus
forward declaration for string
A DpContainer packet header.
static constexpr FwSizeType ID_OFFSET
The offset for the id field.
static constexpr FwSizeType TIME_TAG_OFFSET
The offset for the time tag field.
static constexpr FwSizeType DP_STATE_OFFSET
The offset of the data product state field.
static constexpr FwSizeType PACKET_DESCRIPTOR_OFFSET
The offset for the packet descriptor field.
static constexpr FwSizeType PROC_TYPES_OFFSET
The offset for the processing types field.
static constexpr FwSizeType DATA_SIZE_OFFSET
The offset for the data size field.
static constexpr FwSizeType SIZE
The header size.
U8[DpCfg::CONTAINER_USER_DATA_SIZE] UserData
The type of user data.
static constexpr FwSizeType USER_DATA_OFFSET
The offset for the user data field.
static constexpr FwDpPriorityType PRIORITY_OFFSET
The offset for the priority field.