GCC Code Coverage Report


Directory: ./
File: Fw/DataStructures/SetOrMapImplEntry.hpp
Date: 2026-09-03 22:12:29
Exec Total Coverage
Lines: 17 17 100.0%
Functions: 29 56 51.8%
Branches: 3 4 75.0%

Line Branch Exec Source
1 // ======================================================================
2 // \title SetOrMapImplEntry
3 // \author bocchino
4 // \brief A class template representing an entry for a set or map implementation
5 // ======================================================================
6
7 #ifndef Fw_SetOrMapImplEntry_HPP
8 #define Fw_SetOrMapImplEntry_HPP
9
10 #include "Fw/DataStructures/MapEntryBase.hpp"
11 #include "Fw/FPrimeBasicTypes.hpp"
12
13 namespace Fw {
14
15 template <typename KE, typename VN>
16 class SetOrMapImplEntry final : public MapEntryBase<KE, VN> {
17 // ----------------------------------------------------------------------
18 // Static assertions
19 // ----------------------------------------------------------------------
20
21 static_assert(std::is_default_constructible<KE>::value, "key must be default constructible");
22 static_assert(std::is_assignable<KE&, KE>::value, "key or element must be assignable");
23 static_assert(std::is_default_constructible<VN>::value, "value must be default constructible");
24 static_assert(std::is_assignable<VN&, VN>::value, "value must be assignable");
25
26 public:
27 // ----------------------------------------------------------------------
28 // Public constructors and destructors
29 // ----------------------------------------------------------------------
30
31 //! Zero-argument constructor
32
1/1
✓ Branch 2 taken 177 times.
772 SetOrMapImplEntry() : MapEntryBase<KE, VN>() {}
33
34 //! Constructor providing members
35 153 SetOrMapImplEntry(const KE& keyOrElement, //!< The key or element
36 const VN& valueOrNil //!< The value or Nil
37 )
38
1/1
✓ Branch 2 taken 4 times.
153 : MapEntryBase<KE, VN>(), m_keyOrElement(keyOrElement), m_valueOrNil(valueOrNil) {}
39
40 //! Copy constructor
41 SetOrMapImplEntry(const SetOrMapImplEntry<KE, VN>& entry) : MapEntryBase<KE, VN>() { *this = entry; }
42
43 //! Destructor
44 1292 ~SetOrMapImplEntry() override = default;
45
46 public:
47 // ----------------------------------------------------------------------
48 // Public member functions
49 // ----------------------------------------------------------------------
50
51 //! operator=
52 520 SetOrMapImplEntry<KE, VN>& operator=(const SetOrMapImplEntry<KE, VN>& entry) {
53
1/2
✓ Branch 0 taken 262 times.
✗ Branch 1 not taken.
520 if (this != &entry) {
54 520 this->m_keyOrElement = entry.m_keyOrElement;
55 520 this->m_valueOrNil = entry.m_valueOrNil;
56 }
57 520 return *this;
58 }
59
60 //! Get the key or element associated with this entry
61 //! \return The key or element
62 2587 const KE& getKeyOrElement() const { return this->m_keyOrElement; }
63
64 //! Get the value or nil associated with this entry
65 //! \return The value or nil
66 145 const VN& getValueOrNil() const { return this->m_valueOrNil; }
67
68 //! Set the key or element
69 104 void setKeyOrElement(const KE& keyOrElement //!< The key or element
70 ) {
71 104 this->m_keyOrElement = keyOrElement;
72 104 }
73
74 //! Set the value or Nil
75 1828 void setValueOrNil(const VN& valueOrNil) { this->m_valueOrNil = valueOrNil; }
76
77 public:
78 // ----------------------------------------------------------------------
79 // MapEntryBase implementation
80 // ----------------------------------------------------------------------
81
82 //! Get the key associated with this entry
83 //! \return The key
84 5668 const KE& getKey() const override { return this->m_keyOrElement; }
85
86 //! Get the value associated with this entry
87 //! \return The value
88 1910 const VN& getValue() const override { return this->m_valueOrNil; }
89
90 private:
91 // ----------------------------------------------------------------------
92 // Private member variables
93 // ----------------------------------------------------------------------
94
95 //! The map key or set element
96 KE m_keyOrElement = {};
97
98 //! The value or nil
99 VN m_valueOrNil = {};
100 };
101
102 } // namespace Fw
103
104 #endif
105