summaryrefslogtreecommitdiffstats
path: root/src/Net
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2009-05-18 19:53:51 +0200
committerMatthias Schiffer <matthias@gamezock.de>2009-05-18 19:53:51 +0200
commitfc3c50063f659584b2145addab8236a479a031b7 (patch)
tree0aa7057cb9fa7523ace98e0776d46609de58954e /src/Net
parenta3e566c4d3631076e29f3651554603184b6351a7 (diff)
downloadmad-fc3c50063f659584b2145addab8236a479a031b7.tar
mad-fc3c50063f659584b2145addab8236a479a031b7.zip
Von sigc++ auf boost-signals migriert
Diffstat (limited to 'src/Net')
-rw-r--r--src/Net/ClientConnection.cpp4
-rw-r--r--src/Net/Connection.cpp18
-rw-r--r--src/Net/Connection.h18
-rw-r--r--src/Net/FdManager.cpp11
-rw-r--r--src/Net/FdManager.h6
-rw-r--r--src/Net/Listener.cpp14
-rw-r--r--src/Net/Listener.h8
-rw-r--r--src/Net/Makefile.in4
-rw-r--r--src/Net/ServerConnection.cpp2
-rw-r--r--src/Net/ServerConnection.h2
-rw-r--r--src/Net/ThreadManager.cpp6
-rw-r--r--src/Net/ThreadManager.h6
12 files changed, 46 insertions, 53 deletions
diff --git a/src/Net/ClientConnection.cpp b/src/Net/ClientConnection.cpp
index 688dbc7..087d95f 100644
--- a/src/Net/ClientConnection.cpp
+++ b/src/Net/ClientConnection.cpp
@@ -54,7 +54,7 @@ void ClientConnection::connectionHeader() {
ConnectionHeader header = {'M', 'A', 'D', daemon ? 'D' : 'C', 0, 1, 1, 1};
rawSend((uint8_t*)&header, sizeof(header));
- rawReceive(sizeof(ConnectionHeader), sigc::mem_fun(this, &ClientConnection::connectionHeaderReceiveHandler));
+ rawReceive(sizeof(ConnectionHeader), boost::bind(&ClientConnection::connectionHeaderReceiveHandler, this, _1, _2));
}
void ClientConnection::connect(const IPAddress &address, bool daemon0) throw(Exception) {
@@ -104,7 +104,7 @@ void ClientConnection::connect(const IPAddress &address, bool daemon0) throw(Exc
gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred);
gnutls_transport_set_ptr(session, (gnutls_transport_ptr_t)sock);
- FdManager::get()->registerFd(sock, sigc::mem_fun(this, &ClientConnection::sendReceive));
+ FdManager::get()->registerFd(sock, boost::bind(&ClientConnection::sendReceive, this, _1));
state = CONNECT;
diff --git a/src/Net/Connection.cpp b/src/Net/Connection.cpp
index cf675c9..4e5029f 100644
--- a/src/Net/Connection.cpp
+++ b/src/Net/Connection.cpp
@@ -25,7 +25,7 @@
#include <cstring>
#include <sys/socket.h>
-#include <sigc++/bind.h>
+#include <boost/bind.hpp>
namespace Mad {
namespace Net {
@@ -125,12 +125,12 @@ void Connection::enterReceiveLoop() {
return;
if(_isConnecting())
- ThreadManager::get()->pushWork(sigc::mem_fun(connectedSignal, &sigc::signal<void>::emit));
+ ThreadManager::get()->pushWork(boost::bind((void (boost::signal0<void>::*)())&boost::signal0<void>::operator(), &connectedSignal));
state = PACKET_HEADER;
lock.unlock();
- rawReceive(sizeof(Packet::Data), sigc::mem_fun(this, &Connection::packetHeaderReceiveHandler));
+ rawReceive(sizeof(Packet::Data), boost::bind(&Connection::packetHeaderReceiveHandler, this, _1, _2));
}
void Connection::packetHeaderReceiveHandler(const void *data, unsigned long length) {
@@ -146,13 +146,13 @@ void Connection::packetHeaderReceiveHandler(const void *data, unsigned long leng
header = *(const Packet::Data*)data;
if(header.length == 0) {
- ThreadManager::get()->pushWork(sigc::bind(sigc::mem_fun(receiveSignal, &sigc::signal<void,const Packet&>::emit), Packet(ntohs(header.requestId))));
+ ThreadManager::get()->pushWork(boost::bind((void (boost::signal1<void, const Packet&>::*)(const Packet&))&boost::signal1<void, const Packet&>::operator(), &receiveSignal, Packet(ntohs(header.requestId))));
enterReceiveLoop();
}
else {
state = PACKET_DATA;
- rawReceive(ntohs(header.length), sigc::mem_fun(this, &Connection::packetDataReceiveHandler));
+ rawReceive(ntohs(header.length), boost::bind(&Connection::packetDataReceiveHandler, this, _1, _2));
}
}
@@ -166,7 +166,7 @@ void Connection::packetDataReceiveHandler(const void *data, unsigned long length
return;
}
- ThreadManager::get()->pushWork(sigc::bind(sigc::mem_fun(receiveSignal, &sigc::signal<void,const Packet&>::emit), Packet(ntohs(header.requestId), data, length)));
+ ThreadManager::get()->pushWork(boost::bind((void (boost::signal1<void, const Packet&>::*)(const Packet&))&boost::signal1<void, const Packet&>::operator(), &receiveSignal, Packet(ntohs(header.requestId), data, length)));
enterReceiveLoop();
}
@@ -213,7 +213,7 @@ void Connection::doReceive() {
}
bool Connection::rawReceive(unsigned long length,
- const sigc::slot<void,const void*,unsigned long> &notify)
+ const boost::function2<void,const void*,unsigned long> &notify)
{
if(!isConnected())
return false;
@@ -271,7 +271,7 @@ bool Connection::rawSend(const uint8_t *data, unsigned long length) {
if(!isConnected())
return false;
- Transmission trans = {length, 0, new uint8_t[length], sigc::slot<void,const void*,unsigned long>()};
+ Transmission trans = {length, 0, new uint8_t[length], boost::function2<void,const void*,unsigned long>()};
std::memcpy(trans.data, data, length);
sendLock.lock();
@@ -350,7 +350,7 @@ void Connection::doDisconnect() {
gnutls_deinit(session);
- ThreadManager::get()->pushWork(sigc::mem_fun(disconnectedSignal, &sigc::signal<void>::emit));
+ ThreadManager::get()->pushWork(boost::bind((void (boost::signal0<void>::*)())&boost::signal0<void>::operator(), &disconnectedSignal));
state = DISCONNECTED;
}
diff --git a/src/Net/Connection.h b/src/Net/Connection.h
index 1a3e72b..a0b95ea 100644
--- a/src/Net/Connection.h
+++ b/src/Net/Connection.h
@@ -27,9 +27,9 @@
#include <queue>
#include <string>
#include <gnutls/gnutls.h>
-#include <sigc++/signal.h>
#include <poll.h>
+#include <boost/signal.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/shared_mutex.hpp>
@@ -61,7 +61,7 @@ class Connection {
uint8_t *data;
- sigc::slot<void,const void*,unsigned long> notify;
+ boost::function2<void,const void*,unsigned long> notify;
};
boost::mutex receiveLock;
@@ -72,9 +72,9 @@ class Connection {
Packet::Data header;
- sigc::signal<void,const Packet&> receiveSignal;
- sigc::signal<void> connectedSignal;
- sigc::signal<void> disconnectedSignal;
+ boost::signal1<void,const Packet&> receiveSignal;
+ boost::signal0<void> connectedSignal;
+ boost::signal0<void> disconnectedSignal;
void doHandshake();
@@ -129,7 +129,7 @@ class Connection {
virtual void connectionHeader() = 0;
- bool rawReceive(unsigned long length, const sigc::slot<void,const void*,unsigned long> &notify);
+ bool rawReceive(unsigned long length, const boost::function2<void,const void*,unsigned long> &notify);
bool rawSend(const uint8_t *data, unsigned long length);
void enterReceiveLoop();
@@ -190,9 +190,9 @@ class Connection {
bool send(const Packet &packet);
- sigc::signal<void,const Packet&> signalReceive() const {return receiveSignal;}
- sigc::signal<void> signalConnected() const {return connectedSignal;}
- sigc::signal<void> signalDisconnected() const {return disconnectedSignal;}
+ boost::signal1<void,const Packet&>& signalReceive() {return receiveSignal;}
+ boost::signal0<void>& signalConnected() {return connectedSignal;}
+ boost::signal0<void>& signalDisconnected() {return disconnectedSignal;}
};
}
diff --git a/src/Net/FdManager.cpp b/src/Net/FdManager.cpp
index c7abe73..d8faef4 100644
--- a/src/Net/FdManager.cpp
+++ b/src/Net/FdManager.cpp
@@ -24,9 +24,6 @@
#include <unistd.h>
#include <sys/fcntl.h>
-#include <sigc++/adaptors/hide.h>
-#include <sigc++/bind.h>
-
namespace Mad {
namespace Net {
@@ -43,7 +40,7 @@ FdManager::FdManager() : running(false) {
flags = fcntl(interruptPipe[1], F_GETFL, 0);
fcntl(interruptPipe[1], F_SETFL, flags | O_NONBLOCK);
- registerFd(interruptPipe[0], sigc::hide(sigc::mem_fun(this, &FdManager::readInterrupt)), POLLIN);
+ registerFd(interruptPipe[0], boost::bind(&FdManager::readInterrupt, this), POLLIN);
}
FdManager::~FdManager() {
@@ -54,7 +51,7 @@ FdManager::~FdManager() {
}
-bool FdManager::registerFd(int fd, const sigc::slot<void, short> &handler, short events) {
+bool FdManager::registerFd(int fd, const boost::function1<void, short> &handler, short events) {
struct pollfd pollfd = {fd, events, 0};
boost::lock(handlerLock, eventLock);
@@ -149,11 +146,11 @@ void FdManager::ioThread() {
if(poll(fdarray, count, -1) > 0) {
handlerLock.lock_shared();
- std::queue<sigc::slot<void> > calls;
+ std::queue<boost::function0<void> > calls;
for(size_t n = 0; n < count; ++n) {
if(fdarray[n].revents)
- calls.push(sigc::bind(handlers[fdarray[n].fd], fdarray[n].revents));
+ calls.push(boost::bind(handlers[fdarray[n].fd], fdarray[n].revents));
}
handlerLock.unlock_shared();
diff --git a/src/Net/FdManager.h b/src/Net/FdManager.h
index 406110d..1cb95bc 100644
--- a/src/Net/FdManager.h
+++ b/src/Net/FdManager.h
@@ -22,8 +22,8 @@
#include <map>
#include <poll.h>
-#include <sigc++/signal.h>
+#include <boost/function.hpp>
#include <boost/thread/shared_mutex.hpp>
namespace Mad {
@@ -41,7 +41,7 @@ class FdManager {
bool running;
std::map<int, struct pollfd> pollfds;
- std::map<int, sigc::slot<void, short> > handlers;
+ std::map<int, boost::function1<void, short> > handlers;
int interruptPipe[2];
@@ -64,7 +64,7 @@ class FdManager {
static FdManager *get() {return &fdManager;}
- bool registerFd(int fd, const sigc::slot<void, short> &handler, short events = 0);
+ bool registerFd(int fd, const boost::function1<void, short> &handler, short events = 0);
bool unregisterFd(int fd);
bool setFdEvents(int fd, short events);
diff --git a/src/Net/Listener.cpp b/src/Net/Listener.cpp
index 5bcc353..11cbaf5 100644
--- a/src/Net/Listener.cpp
+++ b/src/Net/Listener.cpp
@@ -27,8 +27,6 @@
#include <cstring>
#include <fcntl.h>
-#include <sigc++/bind.h>
-
namespace Mad {
namespace Net {
@@ -40,8 +38,8 @@ void Listener::acceptHandler(int) {
while((sd = accept(sock, (struct sockaddr*)&sa, &addrlen)) >= 0) {
ServerConnection *con = new ServerConnection(sd, IPAddress(sa), dh_params, x905CertFile, x905KeyFile);
- sigc::connection con1 = con->signalConnected().connect(sigc::bind(sigc::mem_fun(this, &Listener::connectHandler), con));
- sigc::connection con2 = con->signalDisconnected().connect(sigc::bind(sigc::mem_fun(this, &Listener::disconnectHandler), con));
+ boost::signals::connection con1 = con->signalConnected().connect(boost::bind(&Listener::connectHandler, this, con));
+ boost::signals::connection con2 = con->signalDisconnected().connect(boost::bind(&Listener::disconnectHandler, this, con));
connections.insert(std::make_pair(con, std::make_pair(con1, con2)));
@@ -51,7 +49,7 @@ void Listener::acceptHandler(int) {
void Listener::connectHandler(ServerConnection *con) {
- std::map<ServerConnection*, std::pair<sigc::connection, sigc::connection> >::iterator it = connections.find(con);
+ std::map<ServerConnection*, std::pair<boost::signals::connection, boost::signals::connection> >::iterator it = connections.find(con);
if(it == connections.end())
return;
@@ -65,7 +63,7 @@ void Listener::connectHandler(ServerConnection *con) {
}
void Listener::disconnectHandler(ServerConnection *con) {
- std::map<ServerConnection*, std::pair<sigc::connection, sigc::connection> >::iterator it = connections.find(con);
+ std::map<ServerConnection*, std::pair<boost::signals::connection, boost::signals::connection> >::iterator it = connections.find(con);
if(it == connections.end())
return;
@@ -112,11 +110,11 @@ Listener::Listener(const std::string &x905CertFile0, const std::string &x905KeyF
throw Exception("listen()", Exception::INTERNAL_ERRNO, errno);
}
- FdManager::get()->registerFd(sock, sigc::mem_fun(this, &Listener::acceptHandler), POLLIN);
+ FdManager::get()->registerFd(sock, boost::bind(&Listener::acceptHandler, this, _1), POLLIN);
}
Listener::~Listener() {
- for(std::map<ServerConnection*,std::pair<sigc::connection, sigc::connection> >::iterator con = connections.begin(); con != connections.end(); ++con) {
+ for(std::map<ServerConnection*,std::pair<boost::signals::connection, boost::signals::connection> >::iterator con = connections.begin(); con != connections.end(); ++con) {
con->first->disconnect();
delete con->first;
}
diff --git a/src/Net/Listener.h b/src/Net/Listener.h
index 3805403..26dffab 100644
--- a/src/Net/Listener.h
+++ b/src/Net/Listener.h
@@ -26,7 +26,7 @@
#include <map>
#include <string>
-#include <sigc++/connection.h>
+#include <boost/signal.hpp>
namespace Mad {
namespace Net {
@@ -42,9 +42,9 @@ class Listener {
gnutls_dh_params_t dh_params;
- std::map<ServerConnection*, std::pair<sigc::connection, sigc::connection> > connections;
+ std::map<ServerConnection*, std::pair<boost::signals::connection, boost::signals::connection> > connections;
- sigc::signal<void, ServerConnection*> signal;
+ boost::signal1<void, ServerConnection*> signal;
void acceptHandler(int);
@@ -59,7 +59,7 @@ class Listener {
Listener(const std::string &x905CertFile0, const std::string &x905KeyFile0, const IPAddress &address0 = IPAddress()) throw(Exception);
virtual ~Listener();
- sigc::signal<void, ServerConnection*> signalNewConnection() const {return signal;}
+ boost::signal1<void, ServerConnection*>& signalNewConnection() {return signal;}
};
}
diff --git a/src/Net/Makefile.in b/src/Net/Makefile.in
index c51039d..36b924e 100644
--- a/src/Net/Makefile.in
+++ b/src/Net/Makefile.in
@@ -39,6 +39,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 \
@@ -88,6 +89,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@
@@ -219,8 +221,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/Net/ServerConnection.cpp b/src/Net/ServerConnection.cpp
index c415cb3..1f01ce5 100644
--- a/src/Net/ServerConnection.cpp
+++ b/src/Net/ServerConnection.cpp
@@ -77,7 +77,7 @@ ServerConnection::ServerConnection(int sock0, const IPAddress &address, gnutls_d
gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred);
gnutls_transport_set_ptr(session, (gnutls_transport_ptr_t)sock);
- FdManager::get()->registerFd(sock, sigc::mem_fun(this, &ServerConnection::sendReceive));
+ FdManager::get()->registerFd(sock, boost::bind(&ServerConnection::sendReceive, this, _1));
state = CONNECT;
diff --git a/src/Net/ServerConnection.h b/src/Net/ServerConnection.h
index 0870143..d52cd7c 100644
--- a/src/Net/ServerConnection.h
+++ b/src/Net/ServerConnection.h
@@ -44,7 +44,7 @@ class ServerConnection : public Connection {
ServerConnection(int sock0, const IPAddress &address, gnutls_dh_params_t dh_params, const std::string &x905certFile, const std::string &x905keyFile);
virtual void connectionHeader() {
- rawReceive(sizeof(ConnectionHeader), sigc::mem_fun(this, &ServerConnection::connectionHeaderReceiveHandler));
+ rawReceive(sizeof(ConnectionHeader), boost::bind(&ServerConnection::connectionHeaderReceiveHandler, this, _1, _2));
}
public:
diff --git a/src/Net/ThreadManager.cpp b/src/Net/ThreadManager.cpp
index b1f4d4b..71a754e 100644
--- a/src/Net/ThreadManager.cpp
+++ b/src/Net/ThreadManager.cpp
@@ -24,8 +24,6 @@
#include <Common/LogManager.h>
#include <fcntl.h>
-#include <sigc++/bind.h>
-#include <sigc++/hide.h>
namespace Mad {
namespace Net {
@@ -50,7 +48,7 @@ void ThreadManager::workerFunc() {
return;
}
- sigc::slot<void> nextWork = work.front();
+ boost::function0<void> nextWork = work.front();
work.pop();
lock2.unlock();
@@ -85,7 +83,7 @@ void ThreadManager::detach() {
threadLock.unlock();
}
-void ThreadManager::pushWork(const sigc::slot<void> &newWork) {
+void ThreadManager::pushWork(const boost::function0<void> &newWork) {
workLock.lock();
work.push(newWork);
workLock.unlock();
diff --git a/src/Net/ThreadManager.h b/src/Net/ThreadManager.h
index 9394329..fd903af 100644
--- a/src/Net/ThreadManager.h
+++ b/src/Net/ThreadManager.h
@@ -26,8 +26,8 @@
#include <queue>
#include <set>
-#include <sigc++/slot.h>
+#include <boost/function.hpp>
#include <boost/thread/thread.hpp>
#include <boost/thread/condition_variable.hpp>
#include <boost/thread/locks.hpp>
@@ -48,7 +48,7 @@ class ThreadManager : public Common::Initializable {
boost::mutex workLock;
boost::condition_variable workCond;
- std::queue<sigc::slot<void> > work;
+ std::queue<boost::function0<void> > work;
static ThreadManager threadManager;
@@ -81,7 +81,7 @@ class ThreadManager : public Common::Initializable {
void detach();
- void pushWork(const sigc::slot<void> &newWork);
+ void pushWork(const boost::function0<void> &newWork);
static ThreadManager* get() {
return &threadManager;