GCC Code Coverage Report


Directory: ./
File: Fw/Types/LinearBufferTemplate.hpp
Date: 2026-09-03 21:13:48
Exec Total Coverage
Lines: 15 16 93.8%
Functions: 11 11 100.0%
Branches: 4 5 80.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 657414 LinearBufferTemplate() : LinearBufferBase(m_bufferData, MaxSize) {}
31
32 70 LinearBufferTemplate(const U8* args, FwSizeType size) : LinearBufferBase(m_bufferData, MaxSize) {
33
1/1
✓ Branch 5 taken 70 times.
70 const SerializeStatus stat = this->setBuff(args, size);
34 70 FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
35 70 }
36
37 // m_bufferData contents are copied via setBuff below
38 // cppcheck-suppress missingMemberCopy
39 118 LinearBufferTemplate(const LinearBufferTemplate& other) : LinearBufferBase(m_bufferData, MaxSize) {
40
2/2
✓ Branch 11 taken 118 times.
✓ Branch 16 taken 118 times.
118 const SerializeStatus stat = this->setBuff(other.m_bufferData, other.getSize());
41 118 FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
42 118 }
43
44 748086 ~LinearBufferTemplate() override = default;
45
46 1351 LinearBufferTemplate& operator=(const LinearBufferTemplate& other) {
47
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1281 times.
1351 if (this == &other) {
48 return *this;
49 }
50 1351 const SerializeStatus stat = this->setBuff(other.m_bufferData, other.getSize());
51 1351 FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
52 1351 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