diff options
Diffstat (limited to 'src/Common/SystemBackend.h')
-rw-r--r-- | src/Common/SystemBackend.h | 54 |
1 files changed, 35 insertions, 19 deletions
diff --git a/src/Common/SystemBackend.h b/src/Common/SystemBackend.h index 8ba1e7d..c531224 100644 --- a/src/Common/SystemBackend.h +++ b/src/Common/SystemBackend.h @@ -20,24 +20,12 @@ #ifndef MAD_COMMON_SYSTEMBACKEND_H_ #define MAD_COMMON_SYSTEMBACKEND_H_ -#include <stdint.h> -#include <string> -#include <memory> +#include <set> namespace Mad { namespace Common { class SystemBackend { - private: - static std::auto_ptr<SystemBackend> backend; - - protected: - SystemBackend() {} - - static void setBackend(std::auto_ptr<SystemBackend> backend0) { - backend = backend0; - } - public: struct UptimeInfo { unsigned long uptime; @@ -59,26 +47,54 @@ class SystemBackend { float loadAvg15; }; - virtual ~SystemBackend() {} + private: + struct Compare { + bool operator() (const SystemBackend *b1, const SystemBackend *b2) { + if(b1->getPriority() == b2->getPriority()) + return (b1 > b2); + else + return (b1->getPriority() > b2->getPriority()); + } + }; + + static std::set<SystemBackend*, Compare> backends; - virtual UptimeInfo getUptimeInfo() { + protected: + SystemBackend() {} + + static void registerBackend(SystemBackend *backend) { + backends.insert(backend); + } + + static void unregisterBackend(SystemBackend *backend) { + backends.erase(backend); + } + + virtual UptimeInfo uptimeInfo() { UptimeInfo ret = {0, 0}; return ret; } - virtual MemoryInfo getMemoryInfo() { + virtual MemoryInfo memoryInfo() { MemoryInfo ret = {0, 0, 0, 0}; return ret; } - virtual LoadInfo getLoadInfo() { + virtual LoadInfo loadInfo() { LoadInfo ret = {0, 0, 0, 0, 0}; return ret; } - static SystemBackend *getBackend() { - return backend.get(); + virtual int getPriority() const { + return 0; } + + public: + virtual ~SystemBackend() {} + + static UptimeInfo getUptimeInfo(); + static MemoryInfo getMemoryInfo(); + static LoadInfo getLoadInfo(); }; } |