diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Common/Connection.h | 6 | ||||
-rw-r--r-- | src/Common/Request.h | 6 | ||||
-rw-r--r-- | src/Common/RequestHandler.h | 6 | ||||
-rw-r--r-- | src/Net/Connection.h | 18 | ||||
-rw-r--r-- | src/Net/Listener.cpp | 8 | ||||
-rw-r--r-- | src/Net/Listener.h | 8 | ||||
-rw-r--r-- | src/Net/Signals/Connection.h | 22 | ||||
-rw-r--r-- | src/Net/Signals/Connection2.h | 53 | ||||
-rw-r--r-- | src/Net/Signals/GenericSignal.h | 12 | ||||
-rw-r--r-- | src/Net/Signals/Signal0.h | 10 | ||||
-rw-r--r-- | src/Net/Signals/Signal1.h | 12 | ||||
-rw-r--r-- | src/Net/Signals/Signal2.h | 12 | ||||
-rw-r--r-- | src/Net/Signals/Signal20.h | 46 | ||||
-rw-r--r-- | src/Net/Signals/Signal21.h | 47 | ||||
-rw-r--r-- | src/Net/Signals/Signal22.h | 47 | ||||
-rw-r--r-- | src/Net/Signals/SignalBase.h | 43 | ||||
-rw-r--r-- | src/Net/Signals/SignalBase2.h | 53 | ||||
-rw-r--r-- | src/Net/Signals/Signals.h | 3 |
18 files changed, 78 insertions, 334 deletions
diff --git a/src/Common/Connection.h b/src/Common/Connection.h index 6f1cffd..c8ff3e8 100644 --- a/src/Common/Connection.h +++ b/src/Common/Connection.h @@ -39,7 +39,7 @@ class Connection : private boost::noncopyable { private: bool authenticated; - Net::Signals::Signal22<boost::shared_ptr<const XmlPacket>, uint16_t> signalReceive; + Net::Signals::Signal2<boost::shared_ptr<const XmlPacket>, uint16_t> signalReceive; protected: Connection() : authenticated(0) {} @@ -53,10 +53,10 @@ class Connection : private boost::noncopyable { bool sendPacket(const XmlPacket &packet, uint16_t requestId); - Net::Signals::Connection2 connectSignalReceive(const Net::Signals::Signal22<boost::shared_ptr<const XmlPacket>, uint16_t>::slot_type &slot) { + Net::Signals::Connection connectSignalReceive(const Net::Signals::Signal2<boost::shared_ptr<const XmlPacket>, uint16_t>::slot_type &slot) { return signalReceive.connect(slot); } - void disconnectSignalReceive(const Net::Signals::Connection2 &con) { + void disconnectSignalReceive(const Net::Signals::Connection &con) { signalReceive.disconnect(con); } diff --git a/src/Common/Request.h b/src/Common/Request.h index b8477f7..4698ae5 100644 --- a/src/Common/Request.h +++ b/src/Common/Request.h @@ -44,7 +44,7 @@ class Request : public RequestHandler { boost::shared_ptr<const XmlPacket> packet; Net::Exception exception; - Net::Signals::Signal22<boost::shared_ptr<const XmlPacket>, Net::Exception> finished; + Net::Signals::Signal2<boost::shared_ptr<const XmlPacket>, Net::Exception> finished; protected: Request() : isFinished(false) {} @@ -80,10 +80,10 @@ class Request : public RequestHandler { virtual void handlePacket(boost::shared_ptr<const XmlPacket> packet); public: - Net::Signals::Connection2 connectSignalFinished(const Net::Signals::Signal22<boost::shared_ptr<const XmlPacket>, Net::Exception>::slot_type &slot) { + Net::Signals::Connection connectSignalFinished(const Net::Signals::Signal2<boost::shared_ptr<const XmlPacket>, Net::Exception>::slot_type &slot) { return finished.connect(slot); } - void disconnectSignalFinished(const Net::Signals::Connection2 &con) { + void disconnectSignalFinished(const Net::Signals::Connection &con) { finished.disconnect(con); } diff --git a/src/Common/RequestHandler.h b/src/Common/RequestHandler.h index 87fccba..917649e 100644 --- a/src/Common/RequestHandler.h +++ b/src/Common/RequestHandler.h @@ -41,7 +41,7 @@ class RequestHandler : private boost::noncopyable { boost::mutex mutex; - Net::Signals::Signal20 finished; + Net::Signals::Signal0 finished; void callHandlePacket(boost::shared_ptr<const XmlPacket> packet) { boost::lock_guard<boost::mutex> lock(mutex); @@ -64,10 +64,10 @@ class RequestHandler : private boost::noncopyable { public: virtual ~RequestHandler() {} - Net::Signals::Connection2 connectSignalFinished(const Net::Signals::Signal20::slot_type &slot) { + Net::Signals::Connection connectSignalFinished(const Net::Signals::Signal0::slot_type &slot) { return finished.connect(slot); } - void disconnectSignalFinished(const Net::Signals::Connection2 &con) { + void disconnectSignalFinished(const Net::Signals::Connection &con) { finished.disconnect(con); } }; diff --git a/src/Net/Connection.h b/src/Net/Connection.h index 505dcea..e1ca63b 100644 --- a/src/Net/Connection.h +++ b/src/Net/Connection.h @@ -70,9 +70,9 @@ class Connection : boost::noncopyable { Packet::Data header; - Signals::Signal21<boost::shared_ptr<Packet> > receiveSignal; - Signals::Signal20 connectedSignal; - Signals::Signal20 disconnectedSignal; + Signals::Signal1<boost::shared_ptr<Packet> > receiveSignal; + Signals::Signal0 connectedSignal; + Signals::Signal0 disconnectedSignal; bool receiving; unsigned long sending; @@ -171,24 +171,24 @@ class Connection : boost::noncopyable { bool send(const Packet &packet); - Signals::Connection2 connectSignalReceive(const Signals::Signal21<boost::shared_ptr<Packet> >::slot_type &slot) { + Signals::Connection connectSignalReceive(const Signals::Signal1<boost::shared_ptr<Packet> >::slot_type &slot) { return receiveSignal.connect(slot); } - void disconnectSignalReceive(const Signals::Connection2 &connection) { + void disconnectSignalReceive(const Signals::Connection &connection) { receiveSignal.disconnect(connection); } - Signals::Connection2 connectSignalConnected(const Signals::Signal20::slot_type &slot) { + Signals::Connection connectSignalConnected(const Signals::Signal0::slot_type &slot) { return connectedSignal.connect(slot); } - void disconnectSignalConnected(const Signals::Connection2 &connection) { + void disconnectSignalConnected(const Signals::Connection &connection) { connectedSignal.disconnect(connection); } - Signals::Connection2 connectSignalDisconnected(const Signals::Signal20::slot_type &slot) { + Signals::Connection connectSignalDisconnected(const Signals::Signal0::slot_type &slot) { return disconnectedSignal.connect(slot); } - void disconnectSignalDisconnected(const Signals::Connection2 &connection) { + void disconnectSignalDisconnected(const Signals::Connection &connection) { disconnectedSignal.disconnect(connection); } }; diff --git a/src/Net/Listener.cpp b/src/Net/Listener.cpp index b9779ec..6da2762 100644 --- a/src/Net/Listener.cpp +++ b/src/Net/Listener.cpp @@ -39,8 +39,8 @@ void Listener::handleAccept(const boost::system::error_code &error, boost::share con->_setState(Connection::CONNECT); - Signals::Connection2 con1 = con->connectSignalConnected(boost::bind(&Listener::handleConnect, this, con)); - Signals::Connection2 con2 = con->connectSignalDisconnected(boost::bind(&Listener::handleDisconnect, this, con)); + Signals::Connection con1 = con->connectSignalConnected(boost::bind(&Listener::handleConnect, this, con)); + Signals::Connection con2 = con->connectSignalDisconnected(boost::bind(&Listener::handleDisconnect, this, con)); connections.insert(std::make_pair(con, std::make_pair(con1, con2))); @@ -54,7 +54,7 @@ void Listener::handleAccept(const boost::system::error_code &error, boost::share void Listener::handleConnect(boost::shared_ptr<Connection> con) { { boost::lock_guard<boost::mutex> lock(mutex); - std::map<boost::shared_ptr<Connection>, std::pair<Signals::Connection2, Signals::Connection2> >::iterator it = connections.find(con); + std::map<boost::shared_ptr<Connection>, std::pair<Signals::Connection, Signals::Connection> >::iterator it = connections.find(con); if(it == connections.end()) return; @@ -93,7 +93,7 @@ sslContext(Connection::ioService, boost::asio::ssl::context::sslv23) } Listener::~Listener() { - for(std::map<boost::shared_ptr<Connection>,std::pair<Signals::Connection2, Signals::Connection2> >::iterator con = connections.begin(); con != connections.end(); ++con) { + for(std::map<boost::shared_ptr<Connection>,std::pair<Signals::Connection, Signals::Connection> >::iterator con = connections.begin(); con != connections.end(); ++con) { con->first->disconnect(); // TODO wait... } diff --git a/src/Net/Listener.h b/src/Net/Listener.h index 600fcf9..2e25051 100644 --- a/src/Net/Listener.h +++ b/src/Net/Listener.h @@ -38,9 +38,9 @@ class Listener : boost::noncopyable { boost::asio::ip::tcp::acceptor acceptor; boost::asio::ssl::context sslContext; - std::map<boost::shared_ptr<Connection>, std::pair<Signals::Connection2, Signals::Connection2> > connections; + std::map<boost::shared_ptr<Connection>, std::pair<Signals::Connection, Signals::Connection> > connections; - Signals::Signal21<boost::shared_ptr<Connection> > signal; + Signals::Signal1<boost::shared_ptr<Connection> > signal; void handleAccept(const boost::system::error_code &error, boost::shared_ptr<Connection> con); @@ -52,10 +52,10 @@ class Listener : boost::noncopyable { const boost::asio::ip::tcp::endpoint &address0 = boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), 6666)) throw(Exception); virtual ~Listener(); - Signals::Connection2 connectSignalNewConnection(const Signals::Signal21<boost::shared_ptr<Connection> >::slot_type &slot) { + Signals::Connection connectSignalNewConnection(const Signals::Signal1<boost::shared_ptr<Connection> >::slot_type &slot) { return signal.connect(slot); } - void disconnectSignalNewConnection(const Signals::Connection2 &connection) { + void disconnectSignalNewConnection(const Signals::Connection &connection) { signal.disconnect(connection); } }; diff --git a/src/Net/Signals/Connection.h b/src/Net/Signals/Connection.h index 0e66611..7730e13 100644 --- a/src/Net/Signals/Connection.h +++ b/src/Net/Signals/Connection.h @@ -20,22 +20,30 @@ #ifndef MAD_NET_SIGNALS_CONNECTION_H_ #define MAD_NET_SIGNALS_CONNECTION_H_ -#include <boost/signals/connection.hpp> - namespace Mad { namespace Net { namespace Signals { -template <typename SignalType, typename FunctionType> class SignalBase; +class SignalBase; class Connection { private: - template <typename SignalType, typename FunctionType> friend class SignalBase; + friend class SignalBase; + + SignalBase *signal; + unsigned long id; + + Connection(SignalBase *signal0, unsigned long id0) + : signal(signal0), id(id0) {} - boost::signals::connection connection; + public: + bool operator==(const Connection &o) const { + return (signal == o.signal && id == o.id); + } - Connection(const boost::signals::connection &connection0) - : connection(connection0) {} + bool operator<(const Connection &o) const { + return (signal != o.signal) ? (signal < o.signal) : (id < o.id); + } }; } diff --git a/src/Net/Signals/Connection2.h b/src/Net/Signals/Connection2.h deleted file mode 100644 index ab80a61..0000000 --- a/src/Net/Signals/Connection2.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Connection2.h - * - * Copyright (C) 2009 Matthias Schiffer <matthias@gamezock.de> - * - * 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef MAD_NET_SIGNALS_CONNECTION2_H_ -#define MAD_NET_SIGNALS_CONNECTION2_H_ - -namespace Mad { -namespace Net { -namespace Signals { - -class SignalBase2; - -class Connection2 { - private: - friend class SignalBase2; - - SignalBase2 *signal; - unsigned long id; - - Connection2(SignalBase2 *signal0, unsigned long id0) - : signal(signal0), id(id0) {} - - public: - bool operator==(const Connection2 &o) const { - return (signal == o.signal && id == o.id); - } - - bool operator<(const Connection2 &o) const { - return (signal != o.signal) ? (signal < o.signal) : (id < o.id); - } -}; - -} -} -} - -#endif /* MAD_NET_SIGNALS_CONNECTION2_H_ */ diff --git a/src/Net/Signals/GenericSignal.h b/src/Net/Signals/GenericSignal.h index d4fa8df..aa6cfa1 100644 --- a/src/Net/Signals/GenericSignal.h +++ b/src/Net/Signals/GenericSignal.h @@ -20,7 +20,7 @@ #ifndef MAD_NET_SIGNALS_GENERICSIGNAL_H_ #define MAD_NET_SIGNALS_GENERICSIGNAL_H_ -#include "SignalBase2.h" +#include "SignalBase.h" #include <map> #include <boost/thread/locks.hpp> @@ -30,24 +30,24 @@ namespace Net { namespace Signals { template <typename FunctionType> -class GenericSignal : protected SignalBase2 { +class GenericSignal : protected SignalBase { public: typedef FunctionType slot_type; protected: - std::map<Connection2, slot_type> handlers; + std::map<Connection, slot_type> handlers; public: - Connection2 connect(const slot_type &slot) { + Connection connect(const slot_type &slot) { boost::lock_guard<boost::mutex> lock(mutex); - Connection2 con = getNewConnection(); + Connection con = getNewConnection(); handlers.insert(std::make_pair(con, slot)); return con; } - bool disconnect(const Connection2 &connection) { + bool disconnect(const Connection &connection) { boost::lock_guard<boost::mutex> lock(mutex); return handlers.erase(connection); diff --git a/src/Net/Signals/Signal0.h b/src/Net/Signals/Signal0.h index c468135..5c0a691 100644 --- a/src/Net/Signals/Signal0.h +++ b/src/Net/Signals/Signal0.h @@ -20,18 +20,22 @@ #ifndef MAD_NET_SIGNALS_SIGNAL0_H_ #define MAD_NET_SIGNALS_SIGNAL0_H_ -#include "SignalBase.h" +#include "GenericSignal.h" +#include <Net/ThreadManager.h> + +#include <boost/function.hpp> namespace Mad { namespace Net { namespace Signals { -class Signal0 : public SignalBase<boost::signal0<void>, boost::function0<void> > { +class Signal0 : public GenericSignal<boost::function0<void> > { public: void emit() { boost::lock_guard<boost::mutex> lock(mutex); - signal(); + for(std::map<Connection, slot_type>::iterator handler = handlers.begin(); handler != handlers.end(); ++handler) + Net::ThreadManager::get()->pushWork(handler->second); } }; diff --git a/src/Net/Signals/Signal1.h b/src/Net/Signals/Signal1.h index b9649be..331c5cb 100644 --- a/src/Net/Signals/Signal1.h +++ b/src/Net/Signals/Signal1.h @@ -20,19 +20,23 @@ #ifndef MAD_NET_SIGNALS_SIGNAL1_H_ #define MAD_NET_SIGNALS_SIGNAL1_H_ -#include "SignalBase.h" +#include "GenericSignal.h" +#include <Net/ThreadManager.h> + +#include <boost/function.hpp> namespace Mad { namespace Net { namespace Signals { template <typename T1> -class Signal1 : public SignalBase<boost::signal1<void, T1>, boost::function1<void, T1> > { +class Signal1 : public GenericSignal<boost::function1<void, T1> > { public: void emit(T1 arg1) { - boost::lock_guard<boost::mutex> lock(SignalBase<boost::signal1<void, T1>, boost::function1<void, T1> >::mutex); + boost::lock_guard<boost::mutex> lock(this->mutex); - SignalBase<boost::signal1<void, T1>, boost::function1<void, T1> >::signal(arg1); + for(typename std::map<Connection, typename GenericSignal<boost::function1<void, T1> >::slot_type>::iterator handler = this->handlers.begin(); handler != this->handlers.end(); ++handler) + Net::ThreadManager::get()->pushWork(boost::bind(handler->second, arg1)); } }; diff --git a/src/Net/Signals/Signal2.h b/src/Net/Signals/Signal2.h index 374a239..3fb9315 100644 --- a/src/Net/Signals/Signal2.h +++ b/src/Net/Signals/Signal2.h @@ -20,19 +20,23 @@ #ifndef MAD_NET_SIGNALS_SIGNAL2_H_ #define MAD_NET_SIGNALS_SIGNAL2_H_ -#include "SignalBase.h" +#include "GenericSignal.h" +#include <Net/ThreadManager.h> + +#include <boost/function.hpp> namespace Mad { namespace Net { namespace Signals { template <typename T1, typename T2> -class Signal2 : public SignalBase<boost::signal2<void, T1, T2>, boost::function2<void, T1, T2> > { +class Signal2 : public GenericSignal<boost::function2<void, T1, T2> > { public: void emit(T1 arg1, T2 arg2) { - boost::lock_guard<boost::mutex> lock(SignalBase<boost::signal2<void, T1, T2>, boost::function2<void, T1, T2> >::mutex); + boost::lock_guard<boost::mutex> lock(this->mutex); - SignalBase<boost::signal2<void, T1, T2>, boost::function2<void, T1, T2> >::signal(arg1, arg2); + for(typename std::map<Connection, typename GenericSignal<boost::function2<void, T1, T2> >::slot_type>::iterator handler = this->handlers.begin(); handler != this->handlers.end(); ++handler) + Net::ThreadManager::get()->pushWork(boost::bind(handler->second, arg1, arg2)); } }; diff --git a/src/Net/Signals/Signal20.h b/src/Net/Signals/Signal20.h deleted file mode 100644 index 0a12640..0000000 --- a/src/Net/Signals/Signal20.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Signal20.h - * - * Copyright (C) 2009 Matthias Schiffer <matthias@gamezock.de> - * - * 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef MAD_NET_SIGNALS_SIGNAL20_H_ -#define MAD_NET_SIGNALS_SIGNAL20_H_ - -#include "GenericSignal.h" -#include <Net/ThreadManager.h> - -#include <boost/function.hpp> - -namespace Mad { -namespace Net { -namespace Signals { - -class Signal20 : public GenericSignal<boost::function0<void> > { - public: - void emit() { - boost::lock_guard<boost::mutex> lock(mutex); - - for(std::map<Connection2, slot_type>::iterator handler = handlers.begin(); handler != handlers.end(); ++handler) - Net::ThreadManager::get()->pushWork(handler->second); - } -}; - -} -} -} - -#endif /* MAD_NET_SIGNALS_SIGNAL20_H_ */ diff --git a/src/Net/Signals/Signal21.h b/src/Net/Signals/Signal21.h deleted file mode 100644 index 799296f..0000000 --- a/src/Net/Signals/Signal21.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Signal21.h - * - * Copyright (C) 2009 Matthias Schiffer <matthias@gamezock.de> - * - * 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef MAD_NET_SIGNALS_SIGNAL21_H_ -#define MAD_NET_SIGNALS_SIGNAL21_H_ - -#include "GenericSignal.h" -#include <Net/ThreadManager.h> - -#include <boost/function.hpp> - -namespace Mad { -namespace Net { -namespace Signals { - -template <typename T1> -class Signal21 : public GenericSignal<boost::function1<void, T1> > { - public: - void emit(T1 arg1) { - boost::lock_guard<boost::mutex> lock(this->mutex); - - for(typename std::map<Connection2, typename GenericSignal<boost::function1<void, T1> >::slot_type>::iterator handler = this->handlers.begin(); handler != this->handlers.end(); ++handler) - Net::ThreadManager::get()->pushWork(boost::bind(handler->second, arg1)); - } -}; - -} -} -} - -#endif /* MAD_NET_SIGNALS_SIGNAL21_H_ */ diff --git a/src/Net/Signals/Signal22.h b/src/Net/Signals/Signal22.h deleted file mode 100644 index a3b2ac4..0000000 --- a/src/Net/Signals/Signal22.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Signal22.h - * - * Copyright (C) 2009 Matthias Schiffer <matthias@gamezock.de> - * - * 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef MAD_NET_SIGNALS_SIGNAL22_H_ -#define MAD_NET_SIGNALS_SIGNAL22_H_ - -#include "GenericSignal.h" -#include <Net/ThreadManager.h> - -#include <boost/function.hpp> - -namespace Mad { -namespace Net { -namespace Signals { - -template <typename T1, typename T2> -class Signal22 : public GenericSignal<boost::function2<void, T1, T2> > { - public: - void emit(T1 arg1, T2 arg2) { - boost::lock_guard<boost::mutex> lock(this->mutex); - - for(typename std::map<Connection2, typename GenericSignal<boost::function2<void, T1, T2> >::slot_type>::iterator handler = this->handlers.begin(); handler != this->handlers.end(); ++handler) - Net::ThreadManager::get()->pushWork(boost::bind(handler->second, arg1, arg2)); - } -}; - -} -} -} - -#endif /* MAD_NET_SIGNALS_SIGNAL22_H_ */ diff --git a/src/Net/Signals/SignalBase.h b/src/Net/Signals/SignalBase.h index 9e2de62..ea1b1e9 100644 --- a/src/Net/Signals/SignalBase.h +++ b/src/Net/Signals/SignalBase.h @@ -23,54 +23,27 @@ #include "Connection.h" #include <set> -#include <boost/signals.hpp> -#include <boost/thread/locks.hpp> #include <boost/thread/mutex.hpp> namespace Mad { namespace Net { namespace Signals { -template <typename SignalType, typename FunctionType> class SignalBase : private boost::noncopyable { - public: - typedef boost::slot<FunctionType> slot_type; + private: + friend class Connection; - protected: - typedef SignalType signal_type; + unsigned long connectionId; - std::set<boost::signals::connection> connections; + protected: boost::mutex mutex; - signal_type signal; - - SignalBase() {} - ~SignalBase() { - // Wait for other threads - boost::lock_guard<boost::mutex> lock(mutex); + Connection getNewConnection() { + return Connection(this, connectionId++); } - public: - Connection connect(const slot_type &slot) { - boost::lock_guard<boost::mutex> lock(mutex); - - boost::signals::connection con(signal.connect(slot)); - - connections.insert(con); - return con; - } - - void disconnect(const Connection &connection) { - boost::lock_guard<boost::mutex> lock(mutex); - - std::set<boost::signals::connection>::iterator it = connections.find(connection.connection); - - if(it == connections.end()) - return; - - it->disconnect(); - connections.erase(it); - } + SignalBase() : connectionId(0) {} + virtual ~SignalBase() {} }; } diff --git a/src/Net/Signals/SignalBase2.h b/src/Net/Signals/SignalBase2.h deleted file mode 100644 index d5cb0a7..0000000 --- a/src/Net/Signals/SignalBase2.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SignalBase2.h - * - * Copyright (C) 2009 Matthias Schiffer <matthias@gamezock.de> - * - * 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef MAD_SIGNALS_SIGNALBASE2_H_ -#define MAD_SIGNALS_SIGNALBASE2_H_ - -#include "Connection2.h" - -#include <set> -#include <boost/thread/mutex.hpp> - -namespace Mad { -namespace Net { -namespace Signals { - -class SignalBase2 : private boost::noncopyable { - private: - friend class Connection2; - - unsigned long connectionId; - - protected: - boost::mutex mutex; - - Connection2 getNewConnection() { - return Connection2(this, connectionId++); - } - - SignalBase2() : connectionId(0) {} - virtual ~SignalBase2() {} -}; - -} -} -} - -#endif /* MAD_SIGNALS_SIGNALBASE2_H_ */ diff --git a/src/Net/Signals/Signals.h b/src/Net/Signals/Signals.h index b4c9bac..4ee4f95 100644 --- a/src/Net/Signals/Signals.h +++ b/src/Net/Signals/Signals.h @@ -23,8 +23,5 @@ #include "Signal0.h" #include "Signal1.h" #include "Signal2.h" -#include "Signal20.h" -#include "Signal21.h" -#include "Signal22.h" #endif /* MAD_SIGNALS_SIGNALS_H_ */ |