diff options
Diffstat (limited to 'src/Common/SystemBackend.cpp')
-rw-r--r-- | src/Common/SystemBackend.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/Common/SystemBackend.cpp b/src/Common/SystemBackend.cpp index c9be525..0d4b2b7 100644 --- a/src/Common/SystemBackend.cpp +++ b/src/Common/SystemBackend.cpp @@ -22,7 +22,35 @@ namespace Mad { namespace Common { -std::auto_ptr<SystemBackend> SystemBackend::backend(new SystemBackend()); +std::set<SystemBackend*, SystemBackend::Compare> SystemBackend::backends; + + +SystemBackend::UptimeInfo SystemBackend::getUptimeInfo() { + UptimeInfo ret = {0, 0}; + + for(std::set<SystemBackend*>::iterator backend = backends.begin(); backend != backends.end() && ret.uptime == 0; ++backend) + ret = (*backend)->uptimeInfo(); + + return ret; +} + +SystemBackend::MemoryInfo SystemBackend::getMemoryInfo() { + MemoryInfo ret = {0, 0, 0, 0}; + + for(std::set<SystemBackend*>::iterator backend = backends.begin(); backend != backends.end() && ret.totalMem == 0; ++backend) + ret = (*backend)->memoryInfo(); + + return ret; +} + +SystemBackend::LoadInfo SystemBackend::getLoadInfo() { + LoadInfo ret = {0, 0, 0, 0, 0}; + + for(std::set<SystemBackend*>::iterator backend = backends.begin(); backend != backends.end() && ret.currentLoad == 0 && ret.loadAvg1 == 0 && ret.nProcesses == 0; ++backend) + ret = (*backend)->loadInfo(); + + return ret; +} } } |