GCC Code Coverage Report


Directory: Os/
File: Console.cpp
Date: 2026-09-23 21:11:56
Exec Total Coverage
Lines: 0 42 0.0%
Functions: 0 11 0.0%
Branches: 0 19 0.0%

Line Branch Exec Source
1 // ======================================================================
2 // \title Os/Console.cpp
3 // \brief common function implementation for Os::Console
4 // ======================================================================
5 #include <Fw/Types/Assert.hpp>
6 #include <Os/Console.hpp>
7
8 namespace Os {
9 ✗ Console::Console()
10 : ConsoleInterface(),
11 Fw::Logger(),
12 ✗ m_handle_storage(),
13 ✗ m_delegate(*ConsoleInterface::getDelegate(m_handle_storage)) {}
14
15 ✗ Console::~Console() {
16 ✗ FW_ASSERT(&this->m_delegate == reinterpret_cast<ConsoleInterface*>(&this->m_handle_storage[0]));
17 ✗ m_delegate.~ConsoleInterface();
18 ✗ }
19
20 ✗ Console::Console(const Console& other)
21 ✗ : m_handle_storage(), m_delegate(*Console::getDelegate(m_handle_storage, &other.m_delegate)) {
22 ✗ FW_ASSERT(&this->m_delegate == reinterpret_cast<Console*>(&this->m_handle_storage[0]));
23 ✗ }
24
25 ✗ Console& Console::operator=(const Console& other) {
26 ✗ FW_ASSERT(&this->m_delegate == reinterpret_cast<Console*>(&this->m_handle_storage[0]));
27 ✗ if (this != &other) {
28 ✗ this->m_delegate = *ConsoleInterface::getDelegate(m_handle_storage, &other.m_delegate);
29 }
30 ✗ return *this;
31 }
32
33 ✗ void Console::writeMessage(const CHAR* message, const FwSizeType size) {
34 ✗ FW_ASSERT(&this->m_delegate == reinterpret_cast<ConsoleInterface*>(&this->m_handle_storage));
35 ✗ FW_ASSERT(message != nullptr || size == 0);
36 ✗ this->m_delegate.writeMessage(message, size);
37 ✗ }
38
39 ✗ void Console::writeMessage(const Fw::ConstStringBase& message) {
40 ✗ this->writeMessage(message.toChar(), message.length());
41 ✗ }
42
43 ✗ ConsoleHandle* Console::getHandle() {
44 ✗ FW_ASSERT(&this->m_delegate == reinterpret_cast<ConsoleInterface*>(&this->m_handle_storage));
45 ✗ return this->m_delegate.getHandle();
46 }
47
48 ✗ void Console::write(const CHAR* message, const FwSizeType size) {
49 ✗ Console::getSingleton().writeMessage(message, size);
50 ✗ }
51
52 ✗ void Console::write(const Fw::ConstStringBase& message) {
53 ✗ Console::getSingleton().writeMessage(message.toChar(), message.length());
54 ✗ }
55
56 ✗ void Console::init() {
57 // Force trigger on the fly singleton setup
58 ✗ (void)Console::getSingleton();
59 ✗ }
60
61 ✗ Console& Console::getSingleton() {
62 ✗ static Console s_singleton;
63 // Registration happens once: re-registering on every access would silently replace a
64 // logger the project registered after the console singleton was first used
65 static bool s_registered = false;
66 ✗ if (not s_registered) {
67 ✗ s_registered = true;
68 ✗ Fw::Logger::registerLogger(&s_singleton);
69 }
70 ✗ return s_singleton;
71 }
72 } // namespace Os
73