diff options
Diffstat (limited to 'src/modules/SystemBackendPosix/SystemBackendPosix.h')
-rw-r--r-- | src/modules/SystemBackendPosix/SystemBackendPosix.h | 43 |
1 files changed, 7 insertions, 36 deletions
diff --git a/src/modules/SystemBackendPosix/SystemBackendPosix.h b/src/modules/SystemBackendPosix/SystemBackendPosix.h index 6d9b65f..2ec026d 100644 --- a/src/modules/SystemBackendPosix/SystemBackendPosix.h +++ b/src/modules/SystemBackendPosix/SystemBackendPosix.h @@ -33,37 +33,15 @@ namespace Mad { namespace Modules { -// TODO SystemBackendPosix doesn't work !!! - -class SystemBackendPosix : private Common::SystemBackend { +class SystemBackendPosix : public Common::SystemBackend { private: - static SystemBackendPosix *backend; - static std::map<pid_t, boost::function1<void, int> > processes; - - static std::map<pid_t, boost::function2<void, int, const std::string&> > processesWithOutput; - static std::map<pid_t, int> processesWOHandles; - static std::map<pid_t, std::string > processesWOOutput; - - static void setChildHandler(); - - static void childHandler(int); - - static void outputHandler(short events, pid_t pid); - - static std::pair<char**, char**> makeArgs(const std::string &filename, const std::vector<std::string> &argv, const std::vector<std::string> &env); - static void destroyArgs(std::pair<char**, char**> args); - - SystemBackendPosix() { - setChildHandler(); - } - - void fsInfoCallback(int, const std::string &output, const boost::function1<void, const std::vector<Common::SystemManager::FSInfo>& > &callback); + static boost::shared_ptr<SystemBackendPosix> backend; protected: - virtual bool getFSInfo(const boost::function1<void, const std::vector<Common::SystemManager::FSInfo>& > &callback); + virtual bool getFSInfo(std::vector<Common::SystemManager::FSInfo> *fsInfo); - virtual bool shutdown(const boost::function0<void> &callback) {return exec(boost::bind(callback), "/sbin/halt");} - virtual bool reboot(const boost::function0<void> &callback) {return exec(boost::bind(callback), "/sbin/reboot");} + virtual bool shutdown(); + virtual bool reboot(); public: ~SystemBackendPosix(); @@ -72,7 +50,7 @@ class SystemBackendPosix : private Common::SystemBackend { if(backend) return; - backend = new SystemBackendPosix(); + backend.reset(new SystemBackendPosix()); Common::SystemManager::get()->registerBackend(backend); } @@ -81,15 +59,8 @@ class SystemBackendPosix : private Common::SystemBackend { return; Common::SystemManager::get()->unregisterBackend(backend); - delete backend; - backend = 0; + backend.reset(); } - - static bool exec(const boost::function1<void, int> &resultHandler, const std::string &filename, const std::vector<std::string> &argv = std::vector<std::string>(), - const std::vector<std::string> &env = std::vector<std::string>()); - - static bool execWithOutput(const boost::function2<void, int, const std::string&> &resultHandler, const std::string &filename, const std::vector<std::string> &argv = std::vector<std::string>(), - const std::vector<std::string> &env = std::vector<std::string>()); }; } |