| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // ====================================================================== | ||
| 2 | // \title Os/Stub/Memory.hpp | ||
| 3 | // \brief stub implementation for Os::Memory, header and test definitions | ||
| 4 | // ====================================================================== | ||
| 5 | #include <Os/Memory.hpp> | ||
| 6 | #include <cstdio> | ||
| 7 | #ifndef OS_Stub_Memory_HPP | ||
| 8 | #define OS_Stub_Memory_HPP | ||
| 9 | |||
| 10 | namespace Os { | ||
| 11 | namespace Stub { | ||
| 12 | namespace Memory { | ||
| 13 | |||
| 14 | //! MemoryHandle class definition for stub implementations. | ||
| 15 | //! | ||
| 16 | struct StubMemoryHandle : public MemoryHandle {}; | ||
| 17 | |||
| 18 | //! \brief stub implementation of Os::MemoryInterface | ||
| 19 | //! | ||
| 20 | //! Stub implementation of `MemoryInterface` for use as a delegate class handling stub console operations. | ||
| 21 | //! | ||
| 22 | class StubMemory : public MemoryInterface { | ||
| 23 | public: | ||
| 24 | //! \brief constructor | ||
| 25 | //! | ||
| 26 | ✗ | StubMemory() = default; | |
| 27 | |||
| 28 | //! \brief copy constructor | ||
| 29 | StubMemory(const StubMemory& other) = delete; | ||
| 30 | |||
| 31 | //! \brief default copy assignment | ||
| 32 | MemoryInterface& operator=(const MemoryInterface& other) override = delete; | ||
| 33 | |||
| 34 | //! \brief destructor | ||
| 35 | //! | ||
| 36 | ✗ | ~StubMemory() override = default; | |
| 37 | |||
| 38 | // ------------------------------------ | ||
| 39 | // Functions overrides | ||
| 40 | // ------------------------------------ | ||
| 41 | |||
| 42 | //! \brief get system memory usage | ||
| 43 | //! | ||
| 44 | //! This method delegates to the underlying implementation. | ||
| 45 | //! | ||
| 46 | //! \param memory_usage: (output) data structure used to store memory usage | ||
| 47 | //! \return: ERROR when error occurs, OK otherwise. | ||
| 48 | Status _getUsage(Usage& memory_usage) override; | ||
| 49 | |||
| 50 | //! \brief returns the raw console handle | ||
| 51 | //! | ||
| 52 | //! Gets the raw console handle from the implementation. Note: users must include the implementation specific | ||
| 53 | //! header to make any real use of this handle. Otherwise it will be as an opaque type. | ||
| 54 | //! | ||
| 55 | //! \return raw console handle | ||
| 56 | //! | ||
| 57 | MemoryHandle* getHandle() override; | ||
| 58 | |||
| 59 | private: | ||
| 60 | //! File handle for PosixFile | ||
| 61 | StubMemoryHandle m_handle; | ||
| 62 | }; | ||
| 63 | } // namespace Memory | ||
| 64 | } // namespace Stub | ||
| 65 | } // namespace Os | ||
| 66 | |||
| 67 | #endif // OS_Stub_Memory_HPP | ||
| 68 |