GCC Code Coverage Report


Directory: ./
File: Svc/StaticMemory/StaticMemoryComponentImpl.cpp
Date: 2026-09-03 22:12:29
Exec Total Coverage
Lines: 0 20 0.0%
Functions: 0 4 0.0%
Branches: 0 2 0.0%

Line Branch Exec Source
1 // ======================================================================
2 // \title StaticMemoryComponentImpl.cpp
3 // \author mstarch
4 // \brief cpp file for StaticMemory component implementation class
5 //
6 // \copyright
7 // Copyright 2009-2015, by the California Institute of Technology.
8 // ALL RIGHTS RESERVED. United States Government Sponsorship
9 // acknowledged.
10 //
11 // ======================================================================
12
13 #include <Fw/FPrimeBasicTypes.hpp>
14 #include <Svc/StaticMemory/StaticMemoryComponentImpl.hpp>
15 #include "Fw/Types/Assert.hpp"
16
17 namespace Svc {
18
19 // ----------------------------------------------------------------------
20 // Construction, initialization, and destruction
21 // ----------------------------------------------------------------------
22
23 StaticMemoryComponentImpl ::StaticMemoryComponentImpl(const char* const compName)
24 : StaticMemoryComponentBase(compName) {
25 static_assert(
26 (StaticMemoryComponentBase::NUM_BUFFERALLOCATE_INPUT_PORTS >= 0) &&
27 (StaticMemoryComponentBase::NUM_BUFFERALLOCATE_INPUT_PORTS <= std::numeric_limits<FwIndexType>::max()),
28 "NUM_BUFFERALLOCATE_INPUT_PORTS must fit in the positive range of FwIndexType");
29 for (FwIndexType i = 0; i < static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(m_allocated)); i++) {
30 m_allocated[i] = false;
31 }
32 }
33
34 StaticMemoryComponentImpl ::~StaticMemoryComponentImpl() {}
35
36 // ----------------------------------------------------------------------
37 // Handler implementations for user-defined typed input ports
38 // ----------------------------------------------------------------------
39
40 void StaticMemoryComponentImpl ::bufferDeallocate_handler(const FwIndexType portNum, Fw::Buffer& fwBuffer) {
41 FW_ASSERT(portNum < static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(m_static_memory)));
42 FW_ASSERT(m_allocated[portNum],
43 static_cast<FwAssertArgType>(portNum)); // It is also an error to deallocate before returning
44 // Check the memory returned is within the region
45 FW_ASSERT(fwBuffer.getData() >= m_static_memory[portNum]);
46 FW_ASSERT((fwBuffer.getData() + fwBuffer.getSize()) <= (m_static_memory[portNum] + sizeof(m_static_memory[0])),
47 static_cast<FwAssertArgType>(fwBuffer.getSize()),
48 static_cast<FwAssertArgType>(sizeof(m_static_memory[0])));
49 m_allocated[portNum] = false;
50 }
51
52 Fw::Buffer StaticMemoryComponentImpl ::bufferAllocate_handler(const FwIndexType portNum, FwSizeType size) {
53 FW_ASSERT(portNum < static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(m_static_memory)));
54 FW_ASSERT(size <=
55 sizeof(m_static_memory[portNum])); // It is a topology error to ask for too much from this component
56 FW_ASSERT(not m_allocated[portNum],
57 static_cast<FwAssertArgType>(portNum)); // It is also an error to allocate again before returning
58 m_allocated[portNum] = true;
59 Fw::Buffer buffer(m_static_memory[portNum], sizeof(m_static_memory[0]));
60 return buffer;
61 }
62
63 } // end namespace Svc
64