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() = default;
31 
32  LinearBufferTemplate(const U8* args, FwSizeType size) {
33  const SerializeStatus stat = this->setBuff(args, size);
34  FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
35  }
36 
38  const SerializeStatus stat = this->setBuff(other.getBuffAddr(), other.getSize());
39  FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
40  }
41 
42  ~LinearBufferTemplate() override = default;
43 
45  if (this == &other) {
46  return *this;
47  }
48  const SerializeStatus stat = this->setBuff(other.getBuffAddr(), other.getSize());
49  FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
50  return *this;
51  }
52 
53  DEPRECATED(FwSizeType getBuffCapacity() const, "Use getCapacity() instead") { return this->getCapacity(); }
54 
55  FwSizeType getCapacity() const override { return sizeof this->m_bufferData; }
56 
57  U8* getBuffAddr() override { return this->m_bufferData; }
58 
59  const U8* getBuffAddr() const override { return this->m_bufferData; }
60 
61  private:
62  U8 m_bufferData[MaxSize] = {};
63 };
64 
65 } // namespace Fw
66 
67 #endif
Serialization/Deserialization operation was successful.
PlatformSizeType FwSizeType
Serializable::SizeType getSize() const override
Get current buffer size.
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...
SerializeStatus setBuff(const U8 *src, Serializable::SizeType length) override
Set buffer contents from external source.
LinearBufferTemplate(const U8 *args, FwSizeType size)
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:54
const U8 * getBuffAddr() const override
Get buffer address for data reading (const version)
LinearBufferTemplate(const LinearBufferTemplate &other)
size when serialized: buffer + stored size
U8 * getBuffAddr() override
Get buffer address for data filling (non-const version)
FwSizeType getCapacity() const override
Get buffer capacity.
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)