From fc3c50063f659584b2145addab8236a479a031b7 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 18 May 2009 19:53:51 +0200 Subject: Von sigc++ auf boost-signals migriert --- src/modules/Makefile.in | 8 ++++---- src/modules/SystemBackendPosix.cpp | 30 ++++++++++++++---------------- src/modules/SystemBackendPosix.h | 22 ++++++++++++---------- src/modules/SystemBackendProc.cpp | 14 +++++++------- src/modules/SystemBackendProc.h | 6 +++--- src/modules/UserBackendMysql.cpp | 12 ++++++------ src/modules/UserBackendMysql.h | 4 ++-- 7 files changed, 48 insertions(+), 48 deletions(-) (limited to 'src/modules') diff --git a/src/modules/Makefile.in b/src/modules/Makefile.in index 077c7bb..8dc9810 100644 --- a/src/modules/Makefile.in +++ b/src/modules/Makefile.in @@ -42,6 +42,7 @@ DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/argz.m4 \ $(top_srcdir)/m4/ax_boost_base.m4 \ + $(top_srcdir)/m4/ax_boost_signals.m4 \ $(top_srcdir)/m4/ax_boost_thread.m4 \ $(top_srcdir)/m4/ax_lib_mysql.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltdl.m4 $(top_srcdir)/m4/ltoptions.m4 \ @@ -68,8 +69,7 @@ FileLogger_la_OBJECTS = $(am_FileLogger_la_OBJECTS) FileLogger_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(FileLogger_la_LDFLAGS) $(LDFLAGS) -o $@ -am__DEPENDENCIES_1 = -SystemBackendPosix_la_DEPENDENCIES = $(am__DEPENDENCIES_1) +SystemBackendPosix_la_DEPENDENCIES = am_SystemBackendPosix_la_OBJECTS = SystemBackendPosix.lo SystemBackendPosix_la_OBJECTS = $(am_SystemBackendPosix_la_OBJECTS) SystemBackendPosix_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \ @@ -83,6 +83,7 @@ SystemBackendProc_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(SystemBackendProc_la_LDFLAGS) $(LDFLAGS) -o $@ @SYSTEMBACKEND_PROC_TRUE@am_SystemBackendProc_la_rpath = +am__DEPENDENCIES_1 = UserBackendMysql_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) am_UserBackendMysql_la_OBJECTS = UserBackendMysql.lo @@ -123,6 +124,7 @@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BOOST_CPPFLAGS = @BOOST_CPPFLAGS@ BOOST_LDFLAGS = @BOOST_LDFLAGS@ +BOOST_SIGNALS_LIB = @BOOST_SIGNALS_LIB@ BOOST_THREAD_LIB = @BOOST_THREAD_LIB@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ @@ -254,8 +256,6 @@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ -sigc_CFLAGS = @sigc_CFLAGS@ -sigc_LIBS = @sigc_LIBS@ srcdir = @srcdir@ sys_symbol_underscore = @sys_symbol_underscore@ sysconfdir = @sysconfdir@ diff --git a/src/modules/SystemBackendPosix.cpp b/src/modules/SystemBackendPosix.cpp index 21e5c75..4969c6d 100644 --- a/src/modules/SystemBackendPosix.cpp +++ b/src/modules/SystemBackendPosix.cpp @@ -33,8 +33,6 @@ #include #include -#include - #define init SystemBackendPosix_LTX_init #define deinit SystemBackendPosix_LTX_deinit @@ -43,8 +41,8 @@ namespace Modules { SystemBackendPosix *SystemBackendPosix::backend = 0; -std::map > SystemBackendPosix::processes; -std::map > SystemBackendPosix::processesWithOutput; +std::map > SystemBackendPosix::processes; +std::map > SystemBackendPosix::processesWithOutput; std::map SystemBackendPosix::processesWOHandles; std::map SystemBackendPosix::processesWOOutput; @@ -70,7 +68,7 @@ SystemBackendPosix::~SystemBackendPosix() { } -void SystemBackendPosix::fsInfoCallback(int, const std::string &output, const sigc::slot& > &callback) { +void SystemBackendPosix::fsInfoCallback(int, const std::string &output, const boost::function1& > &callback) { std::vector ret; std::istringstream stream(output); std::string str; @@ -99,14 +97,14 @@ void SystemBackendPosix::fsInfoCallback(int, const std::string &output, const si callback(ret); } -bool SystemBackendPosix::getFSInfo(const sigc::slot& > &callback) { +bool SystemBackendPosix::getFSInfo(const boost::function1& > &callback) { std::vector argv; argv.push_back("/bin/df"); argv.push_back("-P"); argv.push_back("-k"); - return execWithOutput(sigc::bind(sigc::mem_fun(this, &SystemBackendPosix::fsInfoCallback), callback), "/bin/df", argv); + return execWithOutput(boost::bind(&SystemBackendPosix::fsInfoCallback, this, _1, _2, callback), "/bin/df", argv); } @@ -115,14 +113,14 @@ void SystemBackendPosix::childHandler(int) { pid_t pid; while((pid = waitpid(-1, &status, WNOHANG)) > 0) { - std::map >::iterator it = processes.find(pid); + std::map >::iterator it = processes.find(pid); if(it != processes.end()) { - Common::ActionManager::get()->add(sigc::bind(it->second, status)); + Common::ActionManager::get()->add(boost::bind(it->second, status)); processes.erase(it); } else { - std::map >::iterator it2 = processesWithOutput.find(pid); + std::map >::iterator it2 = processesWithOutput.find(pid); if(it2 != processesWithOutput.end()) { char buffer[1024]; @@ -133,10 +131,10 @@ void SystemBackendPosix::childHandler(int) { while((n = read(handle, buffer, sizeof(buffer))) > 0) output += std::string(buffer, n); - Net::FdManager::get()->unregisterFd(handle); - close(handle); + //Net::FdManager::get()->unregisterFd(handle); + //close(handle); - Common::ActionManager::get()->add(sigc::bind(it2->second, status, output)); + //Common::ActionManager::get()->add(boost::bind(it2->second, status, output)); processesWithOutput.erase(it2); processesWOHandles.erase(pid); processesWOOutput.erase(pid); @@ -218,7 +216,7 @@ void SystemBackendPosix::destroyArgs(std::pair args) { } } -bool SystemBackendPosix::exec(const sigc::slot &resultHandler, const std::string &filename, const std::vector &argv, const std::vector &env) { +bool SystemBackendPosix::exec(const boost::function1 &resultHandler, const std::string &filename, const std::vector &argv, const std::vector &env) { pid_t pid; std::pair args = makeArgs(filename, argv, env); @@ -239,7 +237,7 @@ bool SystemBackendPosix::exec(const sigc::slot &resultHandler, const return ret; } -bool SystemBackendPosix::execWithOutput(const sigc::slot &resultHandler, const std::string &filename, const std::vector &argv, const std::vector &env) { +bool SystemBackendPosix::execWithOutput(const boost::function2 &resultHandler, const std::string &filename, const std::vector &argv, const std::vector &env) { pid_t pid; std::pair args = makeArgs(filename, argv, env); @@ -268,7 +266,7 @@ bool SystemBackendPosix::execWithOutput(const sigc::slotregisterFd(pipeHandles[0], sigc::bind(sigc::ptr_fun(&SystemBackendPosix::outputHandler), pid), POLLIN); + Net::FdManager::get()->registerFd(pipeHandles[0], boost::bind(&SystemBackendPosix::outputHandler, _1, pid), POLLIN); } dup2(saveStdout, STDOUT_FILENO); // restore old stdout diff --git a/src/modules/SystemBackendPosix.h b/src/modules/SystemBackendPosix.h index b12af6b..6d9b65f 100644 --- a/src/modules/SystemBackendPosix.h +++ b/src/modules/SystemBackendPosix.h @@ -27,18 +27,20 @@ #include #include -#include -#include + +#include namespace Mad { namespace Modules { +// TODO SystemBackendPosix doesn't work !!! + class SystemBackendPosix : private Common::SystemBackend { private: static SystemBackendPosix *backend; - static std::map > processes; + static std::map > processes; - static std::map > processesWithOutput; + static std::map > processesWithOutput; static std::map processesWOHandles; static std::map processesWOOutput; @@ -55,13 +57,13 @@ class SystemBackendPosix : private Common::SystemBackend { setChildHandler(); } - void fsInfoCallback(int, const std::string &output, const sigc::slot& > &callback); + void fsInfoCallback(int, const std::string &output, const boost::function1& > &callback); protected: - virtual bool getFSInfo(const sigc::slot& > &callback); + virtual bool getFSInfo(const boost::function1& > &callback); - virtual bool shutdown(const sigc::slot &callback) {return exec(sigc::hide(callback), "/sbin/halt");} - virtual bool reboot(const sigc::slot &callback) {return exec(sigc::hide(callback), "/sbin/reboot");} + virtual bool shutdown(const boost::function0 &callback) {return exec(boost::bind(callback), "/sbin/halt");} + virtual bool reboot(const boost::function0 &callback) {return exec(boost::bind(callback), "/sbin/reboot");} public: ~SystemBackendPosix(); @@ -83,10 +85,10 @@ class SystemBackendPosix : private Common::SystemBackend { backend = 0; } - static bool exec(const sigc::slot &resultHandler, const std::string &filename, const std::vector &argv = std::vector(), + static bool exec(const boost::function1 &resultHandler, const std::string &filename, const std::vector &argv = std::vector(), const std::vector &env = std::vector()); - static bool execWithOutput(const sigc::slot &resultHandler, const std::string &filename, const std::vector &argv = std::vector(), + static bool execWithOutput(const boost::function2 &resultHandler, const std::string &filename, const std::vector &argv = std::vector(), const std::vector &env = std::vector()); }; diff --git a/src/modules/SystemBackendProc.cpp b/src/modules/SystemBackendProc.cpp index 501f779..68f9cec 100644 --- a/src/modules/SystemBackendProc.cpp +++ b/src/modules/SystemBackendProc.cpp @@ -24,7 +24,7 @@ #include #include -#include +#include #define init SystemBackendProc_LTX_init #define deinit SystemBackendProc_LTX_deinit @@ -34,7 +34,7 @@ namespace Modules { SystemBackendProc *SystemBackendProc::backend = 0; -bool SystemBackendProc::getUptimeInfo(const sigc::slot &callback) { +bool SystemBackendProc::getUptimeInfo(const boost::function2 &callback) { unsigned long uptime = 0, idleTime = 0; uptimeFile.seekg(0, std::ios::beg); @@ -53,12 +53,12 @@ bool SystemBackendProc::getUptimeInfo(const sigc::slotadd(sigc::bind(callback, uptime, idleTime)); + Common::ActionManager::get()->add(boost::bind(callback, uptime, idleTime)); return true; } -bool SystemBackendProc::getMemoryInfo(const sigc::slot &callback) { +bool SystemBackendProc::getMemoryInfo(const boost::function4 &callback) { unsigned long totalMem = 0, freeMem = 0, totalSwap = 0, freeSwap = 0; meminfoFile.seekg(0, std::ios::beg); @@ -90,12 +90,12 @@ bool SystemBackendProc::getMemoryInfo(const sigc::slotadd(sigc::bind(callback, totalMem, freeMem, totalSwap, freeSwap)); + Common::ActionManager::get()->add(boost::bind(callback, totalMem, freeMem, totalSwap, freeSwap)); return true; } -bool SystemBackendProc::getLoadInfo(const sigc::slot &callback) { +bool SystemBackendProc::getLoadInfo(const boost::function5 &callback) { unsigned long currentLoad = 0, nProcesses = 0; float loadAvg1 = 0, loadAvg5 = 0, loadAvg15 = 0; @@ -112,7 +112,7 @@ bool SystemBackendProc::getLoadInfo(const sigc::slotadd(sigc::bind(callback, currentLoad, nProcesses, loadAvg1, loadAvg5, loadAvg15)); + Common::ActionManager::get()->add(boost::bind(callback, currentLoad, nProcesses, loadAvg1, loadAvg5, loadAvg15)); return true; } diff --git a/src/modules/SystemBackendProc.h b/src/modules/SystemBackendProc.h index 7174551..bf19e22 100644 --- a/src/modules/SystemBackendProc.h +++ b/src/modules/SystemBackendProc.h @@ -38,9 +38,9 @@ class SystemBackendProc : private Common::SystemBackend { SystemBackendProc() : uptimeFile("/proc/uptime"), meminfoFile("/proc/meminfo"), loadFile("/proc/loadavg") {} protected: - virtual bool getUptimeInfo(const sigc::slot &callback); - virtual bool getMemoryInfo(const sigc::slot &callback); - virtual bool getLoadInfo(const sigc::slot &callback); + virtual bool getUptimeInfo(const boost::function2 &callback); + virtual bool getMemoryInfo(const boost::function4 &callback); + virtual bool getLoadInfo(const boost::function5 &callback); public: static void registerBackend() { diff --git a/src/modules/UserBackendMysql.cpp b/src/modules/UserBackendMysql.cpp index daea626..da5126a 100644 --- a/src/modules/UserBackendMysql.cpp +++ b/src/modules/UserBackendMysql.cpp @@ -27,7 +27,7 @@ #include -#include +#include #include #define init UserBackendMysql_LTX_init @@ -135,7 +135,7 @@ void UserBackendMysql::configFinished() { } -bool UserBackendMysql::getUserList(const sigc::slot& > &callback) { +bool UserBackendMysql::getUserList(const boost::function1& > &callback) { mysql_ping(mysql); mysql_real_query(mysql, queryListUsers.c_str(), queryListUsers.length()); @@ -155,12 +155,12 @@ bool UserBackendMysql::getUserList(const sigc::slotadd(sigc::bind(callback, users)); + Common::ActionManager::get()->add(boost::bind(callback, users)); return true; } -bool UserBackendMysql::getUserInfo(unsigned long uid, const sigc::slot &callback) { +bool UserBackendMysql::getUserInfo(unsigned long uid, const boost::function1 &callback) { mysql_ping(mysql); std::string query = queryUserById; @@ -186,12 +186,12 @@ bool UserBackendMysql::getUserInfo(unsigned long uid, const sigc::slotadd(sigc::bind(callback, user)); + Common::ActionManager::get()->add(boost::bind(callback, user)); while((row = mysql_fetch_row(result)) != 0) {} } else { - Common::ActionManager::get()->add(sigc::bind(callback, Common::UserInfo())); + Common::ActionManager::get()->add(boost::bind(callback, Common::UserInfo())); } return true; diff --git a/src/modules/UserBackendMysql.h b/src/modules/UserBackendMysql.h index ddd4252..2e4f1ff 100644 --- a/src/modules/UserBackendMysql.h +++ b/src/modules/UserBackendMysql.h @@ -50,8 +50,8 @@ class UserBackendMysql : private Server::UserBackend, private Common::Configurab virtual bool handleConfigEntry(const Common::ConfigEntry &entry, bool); virtual void configFinished(); - virtual bool getUserList(const sigc::slot& > &callback); - virtual bool getUserInfo(unsigned long uid, const sigc::slot &callback); + virtual bool getUserList(const boost::function1& > &callback); + virtual bool getUserInfo(unsigned long uid, const boost::function1 &callback); public: virtual ~UserBackendMysql() { -- cgit v1.2.3