| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // ====================================================================== | ||
| 2 | // \title Os/Stub/Console.hpp | ||
| 3 | // \brief stub implementation for Os::Console, header and test definitions | ||
| 4 | // ====================================================================== | ||
| 5 | #include <Os/Console.hpp> | ||
| 6 | #include <cstdio> | ||
| 7 | #ifndef OS_Stub_Console_HPP | ||
| 8 | #define OS_Stub_Console_HPP | ||
| 9 | |||
| 10 | namespace Os { | ||
| 11 | namespace Stub { | ||
| 12 | namespace Console { | ||
| 13 | |||
| 14 | //! ConsoleHandle class definition for stub implementations. | ||
| 15 | //! | ||
| 16 | struct StubConsoleHandle : public ConsoleHandle {}; | ||
| 17 | |||
| 18 | //! \brief stub implementation of Os::ConsoleInterface | ||
| 19 | //! | ||
| 20 | //! Stub implementation of `ConsoleInterface` for use as a delegate class handling stub console operations. | ||
| 21 | //! | ||
| 22 | class StubConsole : public ConsoleInterface { | ||
| 23 | public: | ||
| 24 | //! \brief constructor | ||
| 25 | //! | ||
| 26 | 1 | StubConsole() = default; | |
| 27 | |||
| 28 | //! \brief copy constructor | ||
| 29 | ✗ | StubConsole(const StubConsole& other) = default; | |
| 30 | |||
| 31 | //! \brief default copy assignment | ||
| 32 | StubConsole& operator=(const StubConsole& other) = default; | ||
| 33 | |||
| 34 | //! \brief destructor | ||
| 35 | //! | ||
| 36 | 2 | ~StubConsole() override = default; | |
| 37 | |||
| 38 | // ------------------------------------ | ||
| 39 | // Functions overrides | ||
| 40 | // ------------------------------------ | ||
| 41 | |||
| 42 | //! \brief write message to console | ||
| 43 | //! | ||
| 44 | //! Write a message to the console with a bounded size. This will use the active file descriptor as the output | ||
| 45 | //! destination. | ||
| 46 | //! | ||
| 47 | //! \param message: raw message to write | ||
| 48 | //! \param size: size of the message to write to the console | ||
| 49 | void writeMessage(const CHAR* message, const FwSizeType size) override; | ||
| 50 | |||
| 51 | //! \brief returns the raw console handle | ||
| 52 | //! | ||
| 53 | //! Gets the raw console handle from the implementation. Note: users must include the implementation specific | ||
| 54 | //! header to make any real use of this handle. Otherwise it will be as an opaque type. | ||
| 55 | //! | ||
| 56 | //! \return raw console handle | ||
| 57 | //! | ||
| 58 | ConsoleHandle* getHandle() override; | ||
| 59 | |||
| 60 | private: | ||
| 61 | //! File handle for PosixFile | ||
| 62 | StubConsoleHandle m_handle; | ||
| 63 | }; | ||
| 64 | } // namespace Console | ||
| 65 | } // namespace Stub | ||
| 66 | } // namespace Os | ||
| 67 | |||
| 68 | #endif // OS_Stub_Console_HPP | ||
| 69 |