diff options
Diffstat (limited to 'src/Common/Backends')
-rw-r--r-- | src/Common/Backends/SystemBackendProc.cpp | 8 | ||||
-rw-r--r-- | src/Common/Backends/SystemBackendProc.h | 16 |
2 files changed, 16 insertions, 8 deletions
diff --git a/src/Common/Backends/SystemBackendProc.cpp b/src/Common/Backends/SystemBackendProc.cpp index e8c7357..37bfaf3 100644 --- a/src/Common/Backends/SystemBackendProc.cpp +++ b/src/Common/Backends/SystemBackendProc.cpp @@ -26,7 +26,9 @@ namespace Mad { namespace Common { namespace Backends { -SystemBackend::UptimeInfo SystemBackendProc::getUptimeInfo() { +SystemBackendProc SystemBackendProc::backend; + +SystemBackend::UptimeInfo SystemBackendProc::uptimeInfo() { UptimeInfo uptime = {0, 0}; uptimeFile.seekg(0, std::ios::beg); @@ -50,7 +52,7 @@ SystemBackend::UptimeInfo SystemBackendProc::getUptimeInfo() { return uptime; } -SystemBackend::MemoryInfo SystemBackendProc::getMemoryInfo() { +SystemBackend::MemoryInfo SystemBackendProc::memoryInfo() { MemoryInfo memInfo = {0, 0, 0, 0}; meminfoFile.seekg(0, std::ios::beg); @@ -86,7 +88,7 @@ SystemBackend::MemoryInfo SystemBackendProc::getMemoryInfo() { return memInfo; } -SystemBackend::LoadInfo SystemBackendProc::getLoadInfo() { +SystemBackend::LoadInfo SystemBackendProc::loadInfo() { LoadInfo loadInfo = {0, 0, 0, 0, 0}; loadFile.seekg(0, std::ios::beg); diff --git a/src/Common/Backends/SystemBackendProc.h b/src/Common/Backends/SystemBackendProc.h index 8caa080..619c996 100644 --- a/src/Common/Backends/SystemBackendProc.h +++ b/src/Common/Backends/SystemBackendProc.h @@ -30,6 +30,8 @@ namespace Backends { class SystemBackendProc : public SystemBackend { private: + static SystemBackendProc backend; + std::ifstream uptimeFile; std::ifstream meminfoFile; std::ifstream loadFile; @@ -37,13 +39,17 @@ class SystemBackendProc : public SystemBackend { SystemBackendProc() : uptimeFile("/proc/uptime"), meminfoFile("/proc/meminfo"), loadFile("/proc/loadavg") {} public: - static void useBackend() { - setBackend(std::auto_ptr<SystemBackend>(new SystemBackendProc())); + static void registerBackend() { + SystemBackend::registerBackend(&backend); + } + + static void unregisterBackend() { + SystemBackend::unregisterBackend(&backend); } - virtual UptimeInfo getUptimeInfo(); - virtual MemoryInfo getMemoryInfo(); - virtual LoadInfo getLoadInfo(); + virtual UptimeInfo uptimeInfo(); + virtual MemoryInfo memoryInfo(); + virtual LoadInfo loadInfo(); }; } |