summaryrefslogtreecommitdiffstats
path: root/src/Common/Backends
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2008-09-24 15:23:27 +0200
committerMatthias Schiffer <matthias@gamezock.de>2008-09-24 15:23:27 +0200
commitbea0bb0ff40dca9e5dba55c697c30e4fffaf0f66 (patch)
tree034ed13ba0214fb8d324cd56b1e1a207f5aff0ff /src/Common/Backends
parentfae8ca32af7407653d21f7cbc4e9ea79751faab8 (diff)
downloadmad-bea0bb0ff40dca9e5dba55c697c30e4fffaf0f66.tar
mad-bea0bb0ff40dca9e5dba55c697c30e4fffaf0f66.zip
Erlaube mehrere System-Backends
Diffstat (limited to 'src/Common/Backends')
-rw-r--r--src/Common/Backends/SystemBackendProc.cpp8
-rw-r--r--src/Common/Backends/SystemBackendProc.h16
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();
};
}