F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
LinearBufferTemplate.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // @file LinearBufferTemplate.hpp
3 // @author F Prime
4 // @brief A linear buffer template parameterized by size
5 // ======================================================================
6 
7 #ifndef FW_LINEAR_BUFFER_TEMPLATE_HPP
8 #define FW_LINEAR_BUFFER_TEMPLATE_HPP
9 
10 #include <Fw/FPrimeBasicTypes.hpp>
11 #include <Fw/Types/Assert.hpp>
13 
14 namespace Fw {
15 
23 template <FwSizeType MaxSize>
24 class LinearBufferTemplate final : public LinearBufferBase {
25  public:
26  enum {
28  };
29 
30  LinearBufferTemplate() : LinearBufferBase(m_bufferData, MaxSize) {}
31 
32  LinearBufferTemplate(const U8* args, FwSizeType size) : LinearBufferBase(m_bufferData, MaxSize) {
33  const SerializeStatus stat = this->setBuff(args, size);
34  FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
35  }
36 
37  // m_bufferData contents are copied via setBuff below
38  // cppcheck-suppress missingMemberCopy
39  LinearBufferTemplate(const LinearBufferTemplate& other) : LinearBufferBase(m_bufferData, MaxSize) {
40  const SerializeStatus stat = this->setBuff(other.m_bufferData, other.getSize());
41  FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
42  }
43 
44  ~LinearBufferTemplate() override = default;
45 
47  if (this == &other) {
48  return *this;
49  }
50  const SerializeStatus stat = this->setBuff(other.m_bufferData, other.getSize());
51  FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
52  return *this;
53  }
54 
55  DEPRECATED(FwSizeType getBuffCapacity() const, "Use getCapacity() instead") { return this->getCapacity(); }
56 
57  private:
58  U8 m_bufferData[MaxSize];
59 };
60 
61 } // namespace Fw
62 
63 #endif
Serialization/Deserialization operation was successful.
SerializeStatus setBuff(const U8 *src, Serializable::SizeType length) override
Set buffer contents from external source.
PlatformSizeType FwSizeType
Serializable::SizeType getSize() const override
Get current buffer size.
Serializable::SizeType getCapacity() const override
Get buffer capacity.
SerializeStatus
forward declaration for string
static constexpr Serializable::SizeType STATIC_SERIALIZED_SIZE(Serializable::SizeType maxSize)
Get the static serialized size of a buffer This is the max size of the buffer data plus the size of t...
LinearBufferTemplate(const U8 *args, FwSizeType size)
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:54
LinearBufferTemplate(const LinearBufferTemplate &other)
size when serialized: buffer + stored size
Implementation of malloc based allocator.
~LinearBufferTemplate() override=default
#define FW_ASSERT(...)
Definition: Assert.hpp:14
DEPRECATED(FwSizeType getBuffCapacity() const, "Use getCapacity() instead")
LinearBufferTemplate & operator=(const LinearBufferTemplate &other)