GCC Code Coverage Report


Directory: ./
File: Svc/FileDispatcher/FileDispatcher.cpp
Date: 2026-09-23 22:11:34
Exec Total Coverage
Lines: 0 41 0.0%
Functions: 0 6 0.0%
Branches: 0 23 0.0%

Line Branch Exec Source
1 // ======================================================================
2 // \title FileDispatcher.cpp
3 // \author tcanham
4 // \brief cpp file for FileDispatcher component implementation class
5 // ======================================================================
6
7 #include "Svc/FileDispatcher/FileDispatcher.hpp"
8 #include "Fw/Types/StringUtils.hpp"
9
10 namespace Svc {
11
12 // ----------------------------------------------------------------------
13 // Component construction and destruction
14 // ----------------------------------------------------------------------
15
16 ✗ FileDispatcher ::FileDispatcher(const char* const compName) : FileDispatcherComponentBase(compName) {
17 // disable entries
18 ✗ for (FwSizeType i = 0; i < Svc::FileDispatcherCfg::FILE_DISPATCHER_MAX_TABLE_SIZE; i++) {
19 ✗ this->m_dispatchTable.entries[i].enabled = false;
20 }
21 ✗ this->m_dispatchTable.numEntries = 0;
22 ✗ }
23
24 ✗ FileDispatcher ::~FileDispatcher() {}
25
26 ✗ void FileDispatcher ::configure(const FileDispatcherTable& table) {
27 // validate table
28 ✗ FW_ASSERT(table.numEntries <= Svc::FileDispatcherCfg::FILE_DISPATCHER_MAX_TABLE_SIZE);
29 ✗ for (FwSizeType entry = 0; entry < table.numEntries; entry++) {
30 ✗ FW_ASSERT(table.entries[entry].port.e < Svc::FileDispatcherCfg::FileDispatchPort::MAX_FILE_DISPATCH_PORTS,
31 table.entries[entry].port.e); // valid, non-sentinel output port
32 ✗ FW_ASSERT(table.entries[entry].fileExt.length() > 0,
33 static_cast<FwAssertArgType>(table.entries[entry].fileExt.length())); // non-zero length
34 // Copy over table entry
35 ✗ this->m_dispatchTable.entries[entry].port = table.entries[entry].port;
36 ✗ this->m_dispatchTable.entries[entry].fileExt = table.entries[entry].fileExt;
37 ✗ this->m_dispatchTable.entries[entry].enabled = table.entries[entry].enabled;
38 }
39 // Set number of entries
40 ✗ this->m_dispatchTable.numEntries = table.numEntries;
41 ✗ }
42
43 // ----------------------------------------------------------------------
44 // Handler implementations for typed input ports
45 // ----------------------------------------------------------------------
46
47 ✗ void FileDispatcher ::fileAnnounceRecv_handler(FwIndexType portNum, Fw::StringBase& file_name) {
48 // determine file extension and dispatch accordingly
49 ✗ FW_ASSERT(this->m_dispatchTable.numEntries <= Svc::FileDispatcherCfg::FILE_DISPATCHER_MAX_TABLE_SIZE,
50 static_cast<FwAssertArgType>(this->m_dispatchTable.numEntries));
51
52 // walk table to find match
53 ✗ for (FwSizeType i = 0; i < this->m_dispatchTable.numEntries; i++) {
54 ✗ if (!this->m_dispatchTable.entries[i].enabled) {
55 ✗ continue;
56 }
57
58 ✗ auto loc = Fw::StringUtils::substring_find_last(file_name.toChar(), file_name.length(),
59 this->m_dispatchTable.entries[i].fileExt.toChar(),
60 this->m_dispatchTable.entries[i].fileExt.length());
61
62 ✗ if ((loc != -1) && // matches at all
63 ✗ (file_name.length() - this->m_dispatchTable.entries[i].fileExt.length() ==
64 ✗ static_cast<FwSizeType>(loc)) // match at end of string
65 ) {
66 // dispatch on this port, if connected
67 ✗ if (this->isConnected_fileDispatch_OutputPort(this->m_dispatchTable.entries[i].port.e)) {
68 ✗ this->fileDispatch_out(this->m_dispatchTable.entries[i].port.e, file_name);
69 ✗ this->log_ACTIVITY_HI_FileDispatched(file_name, this->m_dispatchTable.entries[i].port);
70 } else {
71 ✗ this->log_WARNING_LO_FileDispatchPortNotConnected(file_name, this->m_dispatchTable.entries[i].port);
72 }
73 }
74 }
75 ✗ }
76
77 // ----------------------------------------------------------------------
78 // Handler implementations for commands
79 // ----------------------------------------------------------------------
80
81 ✗ void FileDispatcher ::ENABLE_DISPATCH_cmdHandler(FwOpcodeType opCode,
82 U32 cmdSeq,
83 const Svc::FileDispatcherCfg::FileDispatchPort& file_type,
84 const Fw::Enabled& enable) {
85 ✗ FW_ASSERT(this->m_dispatchTable.numEntries <= Svc::FileDispatcherCfg::FILE_DISPATCHER_MAX_TABLE_SIZE,
86 static_cast<FwAssertArgType>(this->m_dispatchTable.numEntries));
87 ✗ for (FwSizeType i = 0; i < this->m_dispatchTable.numEntries; i++) {
88 ✗ if (this->m_dispatchTable.entries[i].port == file_type) {
89 ✗ this->m_dispatchTable.entries[i].enabled = (enable == Fw::Enabled::ENABLED);
90 }
91 }
92 ✗ this->log_ACTIVITY_HI_FileDispatchState(file_type, enable);
93 ✗ this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
94 ✗ }
95
96 ✗ void FileDispatcher ::pingIn_handler(FwIndexType portNum, U32 key) {
97 // return key
98 ✗ this->pingOut_out(0, key);
99 ✗ }
100
101 } // namespace Svc
102