GCC Code Coverage Report


Directory: ./
File: Fw/Types/LinearBufferTemplate.hpp
Date: 2026-09-03 22:12:29
Exec Total Coverage
Lines: 11 12 91.7%
Functions: 6 8 75.0%
Branches: 3 4 75.0%

Line Branch Exec Source
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>
12 #include <Fw/Types/Serializable.hpp>
13
14 namespace Fw {
15
16 //! A linear buffer template parameterized by buffer size
17 //!
18 //! This class template provides a fixed-size linear serialization buffer
19 //! derived from LinearBufferBase. It replaces hand-coded concrete buffer
20 //! classes that share identical structure, eliminating boilerplate.
21 //!
22 //! \tparam MaxSize Maximum buffer capacity in bytes
23 template <FwSizeType MaxSize>
24 class LinearBufferTemplate final : public LinearBufferBase {
25 public:
26 enum {
27 SERIALIZED_SIZE = STATIC_SERIALIZED_SIZE(MaxSize), //!< size when serialized: buffer + stored size
28 };
29
30 6578 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 4 LinearBufferTemplate(const LinearBufferTemplate& other) : LinearBufferBase(m_bufferData, MaxSize) {
40
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 const SerializeStatus stat = this->setBuff(other.m_bufferData, other.getSize());
41 4 FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
42 4 }
43
44 13164 ~LinearBufferTemplate() override = default;
45
46 3514 LinearBufferTemplate& operator=(const LinearBufferTemplate& other) {
47
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3514 times.
3514 if (this == &other) {
48 return *this;
49 }
50 3514 const SerializeStatus stat = this->setBuff(other.m_bufferData, other.getSize());
51 3514 FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
52 3514 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
64