From ad7ee8df8ac73ef7754ccf1d5fb442ec23c879f1 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 27 Nov 2008 22:15:00 +0100 Subject: SystemBackendProc zum Modul gemacht --- src/modules/SystemBackendProc.h | 67 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/modules/SystemBackendProc.h (limited to 'src/modules/SystemBackendProc.h') diff --git a/src/modules/SystemBackendProc.h b/src/modules/SystemBackendProc.h new file mode 100644 index 0000000..db3c743 --- /dev/null +++ b/src/modules/SystemBackendProc.h @@ -0,0 +1,67 @@ +/* + * SystemBackendProc.h + * + * Copyright (C) 2008 Matthias Schiffer + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef MAD_MODULE_SYSTEMBACKENDPROC_H_ +#define MAD_MODULE_SYSTEMBACKENDPROC_H_ + +#include + +#include + +namespace Mad { +namespace Modules { + +class SystemBackendProc : public Common::SystemBackend { + private: + static SystemBackendProc *backend; + + std::ifstream uptimeFile; + std::ifstream meminfoFile; + std::ifstream loadFile; + + SystemBackendProc() : uptimeFile("/proc/uptime"), meminfoFile("/proc/meminfo"), loadFile("/proc/loadavg") {} + + protected: + virtual bool uptimeInfo(const sigc::slot &callback); + virtual bool memoryInfo(const sigc::slot &callback); + virtual bool loadInfo(const sigc::slot &callback); + + public: + static void registerBackend() { + if(backend) + return; + + backend = new SystemBackendProc(); + SystemBackend::registerBackend(backend); + } + + static void unregisterBackend() { + if(!backend) + return; + + SystemBackend::unregisterBackend(backend); + delete backend; + backend = 0; + } +}; + +} +} + +#endif /* MAD_MODULE_SYSTEMBACKENDPROC_H_ */ -- cgit v1.2.3