F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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"
11 #include "Fw/Dp/DpStateEnumAc.hpp"
12 #include "Fw/Time/Time.hpp"
14 #include "Utils/Hash/Hash.hpp"
17 
18 namespace Fw {
19 
21 class DpContainer {
22  public:
23  // ----------------------------------------------------------------------
24  // Constants and Types
25  // ----------------------------------------------------------------------
26 
28  struct Header {
32  static constexpr FwSizeType PACKET_DESCRIPTOR_OFFSET = 0;
36  static constexpr FwDpPriorityType PRIORITY_OFFSET = ID_OFFSET + sizeof(FwDpIdType);
48  static constexpr FwSizeType SIZE = DATA_SIZE_OFFSET + sizeof(FwSizeStoreType);
49  };
50 
59 
60  public:
61  // ----------------------------------------------------------------------
62  // Constructors and destructors
63  // ----------------------------------------------------------------------
64 
67  const Fw::Buffer& buffer
68  );
69 
71  DpContainer();
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 
134  void setId(FwDpIdType id
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
203  return Header::SIZE + HASH_DIGEST_LENGTH + this->m_dataSize;
204  }
205 
209 
213 
215  void setDataHash(Utils::HashBuffer hash
216  );
217 
219  void updateDataHash();
220 
223  Utils::HashBuffer& computedHash
224  ) const;
225 
226  public:
227  // ----------------------------------------------------------------------
228  // Public static functions
229  // ----------------------------------------------------------------------
230 
232  static constexpr FwSizeType getPacketSizeForDataSize(FwSizeType dataSize
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.
Definition: DpContainer.hpp:21
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.
Definition: DpContainer.hpp:54
DpContainer()
Constructor for container with default initialization.
Definition: DpContainer.cpp:28
DpCfg::ProcType::SerialType getProcTypes() const
Utils::HashBuffer getDataHash() const
FwDpPriorityType m_priority
The priority.
Header::UserData m_userData
The user data.
FwDpIdType getId() const
Definition: DpContainer.hpp:91
void setId(FwDpIdType id)
Set the id.
static constexpr FwSizeType MIN_PACKET_SIZE
Definition: DpContainer.hpp:58
void updateHeaderHash()
Compute and set the header hash.
DpContainer & operator=(const DpContainer &src)=default
Copy assignment operator.
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
Definition: DpContainer.hpp:99
Fw::DpState getState() const
Get the product state.
Fw::SerializeStatus deserializeHeader()
Definition: DpContainer.cpp:38
Utils::HashBuffer getHeaderHash() const
virtual ~DpContainer()
Destructor.
Definition: DpContainer.hpp:74
Fw::ExternalSerializeBufferWithMemberCopy m_dataBuffer
DpState getDpState() const
Get the data product state.
Time m_timeTag
The time tag.
FwDpIdType m_id
Success::T checkHeaderHash(Utils::HashBuffer &storedHash, Utils::HashBuffer &computedHash) const
Check the header hash.
void serializeHeader()
Definition: DpContainer.cpp:91
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
Definition: DpContainer.hpp:95
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.
Definition: DpContainer.hpp:52
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.
Definition: Time.hpp:9
@ SERIALIZED_SIZE
Definition: Time.hpp:13
A container class for holding a hash buffer.
Definition: HashBuffer.hpp:26
@ CONTAINER_USER_DATA_SIZE
SerializeStatus
forward declaration for string
A DpContainer packet header.
Definition: DpContainer.hpp:28
static constexpr FwSizeType ID_OFFSET
The offset for the id field.
Definition: DpContainer.hpp:34
static constexpr FwSizeType TIME_TAG_OFFSET
The offset for the time tag field.
Definition: DpContainer.hpp:38
static constexpr FwSizeType DP_STATE_OFFSET
The offset of the data product state field.
Definition: DpContainer.hpp:44
static constexpr FwSizeType PACKET_DESCRIPTOR_OFFSET
The offset for the packet descriptor field.
Definition: DpContainer.hpp:32
static constexpr FwSizeType PROC_TYPES_OFFSET
The offset for the processing types field.
Definition: DpContainer.hpp:40
static constexpr FwSizeType DATA_SIZE_OFFSET
The offset for the data size field.
Definition: DpContainer.hpp:46
static constexpr FwSizeType SIZE
The header size.
Definition: DpContainer.hpp:48
U8[DpCfg::CONTAINER_USER_DATA_SIZE] UserData
The type of user data.
Definition: DpContainer.hpp:30
static constexpr FwSizeType USER_DATA_OFFSET
The offset for the user data field.
Definition: DpContainer.hpp:42
static constexpr FwDpPriorityType PRIORITY_OFFSET
The offset for the priority field.
Definition: DpContainer.hpp:36