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