From fd7e9b8c4637679a9fe2a142771f7f977120df4a Mon Sep 17 00:00:00 2001 From: Martin Hurton Date: Sat, 29 Jun 2013 11:24:46 +0200 Subject: [PATCH] Use generic session class whenever possible --- src/dealer.cpp | 12 ------------ src/dealer.hpp | 15 --------------- src/pair.cpp | 12 ------------ src/pair.hpp | 15 --------------- src/pub.cpp | 12 ------------ src/pub.hpp | 15 --------------- src/pull.cpp | 12 ------------ src/pull.hpp | 15 --------------- src/push.cpp | 12 ------------ src/push.hpp | 15 --------------- src/rep.cpp | 12 ------------ src/rep.hpp | 15 --------------- src/req.cpp | 8 ++++---- src/req.hpp | 2 +- src/router.cpp | 12 ------------ src/router.hpp | 15 --------------- src/session_base.cpp | 43 +------------------------------------------ src/stream.cpp | 12 ------------ src/stream.hpp | 15 --------------- src/sub.cpp | 12 ------------ src/sub.hpp | 15 --------------- src/xpub.cpp | 12 ------------ src/xpub.hpp | 15 --------------- src/xsub.cpp | 12 ------------ src/xsub.hpp | 15 --------------- 25 files changed, 6 insertions(+), 344 deletions(-) diff --git a/src/dealer.cpp b/src/dealer.cpp index 55dd8c8e..8b5b8d66 100644 --- a/src/dealer.cpp +++ b/src/dealer.cpp @@ -113,15 +113,3 @@ void zmq::dealer_t::xpipe_terminated (pipe_t *pipe_) fq.pipe_terminated (pipe_); lb.pipe_terminated (pipe_); } - -zmq::dealer_session_t::dealer_session_t (io_thread_t *io_thread_, bool connect_, - socket_base_t *socket_, const options_t &options_, - const address_t *addr_) : - session_base_t (io_thread_, connect_, socket_, options_, addr_) -{ -} - -zmq::dealer_session_t::~dealer_session_t () -{ -} - diff --git a/src/dealer.hpp b/src/dealer.hpp index 5f5f0d4f..6b91b06a 100644 --- a/src/dealer.hpp +++ b/src/dealer.hpp @@ -69,21 +69,6 @@ namespace zmq const dealer_t &operator = (const dealer_t&); }; - class dealer_session_t : public session_base_t - { - public: - - dealer_session_t (zmq::io_thread_t *io_thread_, bool connect_, - zmq::socket_base_t *socket_, const options_t &options_, - const address_t *addr_); - ~dealer_session_t (); - - private: - - dealer_session_t (const dealer_session_t&); - const dealer_session_t &operator = (const dealer_session_t&); - }; - } #endif diff --git a/src/pair.cpp b/src/pair.cpp index 808cf4cf..342e40b6 100644 --- a/src/pair.cpp +++ b/src/pair.cpp @@ -117,15 +117,3 @@ bool zmq::pair_t::xhas_out () return pipe->check_write (); } - -zmq::pair_session_t::pair_session_t (io_thread_t *io_thread_, bool connect_, - socket_base_t *socket_, const options_t &options_, - const address_t *addr_) : - session_base_t (io_thread_, connect_, socket_, options_, addr_) -{ -} - -zmq::pair_session_t::~pair_session_t () -{ -} - diff --git a/src/pair.hpp b/src/pair.hpp index 2bb6e330..507d4e3f 100644 --- a/src/pair.hpp +++ b/src/pair.hpp @@ -57,21 +57,6 @@ namespace zmq const pair_t &operator = (const pair_t&); }; - class pair_session_t : public session_base_t - { - public: - - pair_session_t (zmq::io_thread_t *io_thread_, bool connect_, - socket_base_t *socket_, const options_t &options_, - const address_t *addr_); - ~pair_session_t (); - - private: - - pair_session_t (const pair_session_t&); - const pair_session_t &operator = (const pair_session_t&); - }; - } #endif diff --git a/src/pub.cpp b/src/pub.cpp index c698f7ab..e84f3c30 100644 --- a/src/pub.cpp +++ b/src/pub.cpp @@ -41,15 +41,3 @@ bool zmq::pub_t::xhas_in () { return false; } - -zmq::pub_session_t::pub_session_t (io_thread_t *io_thread_, bool connect_, - socket_base_t *socket_, const options_t &options_, - const address_t *addr_) : - xpub_session_t (io_thread_, connect_, socket_, options_, addr_) -{ -} - -zmq::pub_session_t::~pub_session_t () -{ -} - diff --git a/src/pub.hpp b/src/pub.hpp index 8cff057c..4fe3a79d 100644 --- a/src/pub.hpp +++ b/src/pub.hpp @@ -47,21 +47,6 @@ namespace zmq const pub_t &operator = (const pub_t&); }; - class pub_session_t : public xpub_session_t - { - public: - - pub_session_t (zmq::io_thread_t *io_thread_, bool connect_, - zmq::socket_base_t *socket_, const options_t &options_, - const address_t *addr_); - ~pub_session_t (); - - private: - - pub_session_t (const pub_session_t&); - const pub_session_t &operator = (const pub_session_t&); - }; - } #endif diff --git a/src/pull.cpp b/src/pull.cpp index 706553bb..80a2d50e 100644 --- a/src/pull.cpp +++ b/src/pull.cpp @@ -60,15 +60,3 @@ bool zmq::pull_t::xhas_in () { return fq.has_in (); } - -zmq::pull_session_t::pull_session_t (io_thread_t *io_thread_, bool connect_, - socket_base_t *socket_, const options_t &options_, - const address_t *addr_) : - session_base_t (io_thread_, connect_, socket_, options_, addr_) -{ -} - -zmq::pull_session_t::~pull_session_t () -{ -} - diff --git a/src/pull.hpp b/src/pull.hpp index 24e6b788..c7386cfd 100644 --- a/src/pull.hpp +++ b/src/pull.hpp @@ -59,21 +59,6 @@ namespace zmq }; - class pull_session_t : public session_base_t - { - public: - - pull_session_t (zmq::io_thread_t *io_thread_, bool connect_, - socket_base_t *socket_, const options_t &options_, - const address_t *addr_); - ~pull_session_t (); - - private: - - pull_session_t (const pull_session_t&); - const pull_session_t &operator = (const pull_session_t&); - }; - } #endif diff --git a/src/push.cpp b/src/push.cpp index 3329b2fc..4833bf3c 100644 --- a/src/push.cpp +++ b/src/push.cpp @@ -60,15 +60,3 @@ bool zmq::push_t::xhas_out () { return lb.has_out (); } - -zmq::push_session_t::push_session_t (io_thread_t *io_thread_, bool connect_, - socket_base_t *socket_, const options_t &options_, - const address_t *addr_) : - session_base_t (io_thread_, connect_, socket_, options_, addr_) -{ -} - -zmq::push_session_t::~push_session_t () -{ -} - diff --git a/src/push.hpp b/src/push.hpp index 136cf9c7..35b05950 100644 --- a/src/push.hpp +++ b/src/push.hpp @@ -58,21 +58,6 @@ namespace zmq const push_t &operator = (const push_t&); }; - class push_session_t : public session_base_t - { - public: - - push_session_t (zmq::io_thread_t *io_thread_, bool connect_, - socket_base_t *socket_, const options_t &options_, - const address_t *addr_); - ~push_session_t (); - - private: - - push_session_t (const push_session_t&); - const push_session_t &operator = (const push_session_t&); - }; - } #endif diff --git a/src/rep.cpp b/src/rep.cpp index a1f7d406..a45e6352 100644 --- a/src/rep.cpp +++ b/src/rep.cpp @@ -121,15 +121,3 @@ bool zmq::rep_t::xhas_out () return router_t::xhas_out (); } - -zmq::rep_session_t::rep_session_t (io_thread_t *io_thread_, bool connect_, - socket_base_t *socket_, const options_t &options_, - const address_t *addr_) : - router_session_t (io_thread_, connect_, socket_, options_, addr_) -{ -} - -zmq::rep_session_t::~rep_session_t () -{ -} - diff --git a/src/rep.hpp b/src/rep.hpp index 7da55f1b..027b4643 100644 --- a/src/rep.hpp +++ b/src/rep.hpp @@ -58,21 +58,6 @@ namespace zmq }; - class rep_session_t : public router_session_t - { - public: - - rep_session_t (zmq::io_thread_t *io_thread_, bool connect_, - zmq::socket_base_t *socket_, const options_t &options_, - const address_t *addr_); - ~rep_session_t (); - - private: - - rep_session_t (const rep_session_t&); - const rep_session_t &operator = (const rep_session_t&); - }; - } #endif diff --git a/src/req.cpp b/src/req.cpp index f4c2c3d7..fd356a28 100644 --- a/src/req.cpp +++ b/src/req.cpp @@ -137,7 +137,7 @@ bool zmq::req_t::xhas_out () zmq::req_session_t::req_session_t (io_thread_t *io_thread_, bool connect_, socket_base_t *socket_, const options_t &options_, const address_t *addr_) : - dealer_session_t (io_thread_, connect_, socket_, options_, addr_), + session_base_t (io_thread_, connect_, socket_, options_, addr_), state (bottom) { } @@ -152,15 +152,15 @@ int zmq::req_session_t::push_msg (msg_t *msg_) case bottom: if (msg_->flags () == msg_t::more && msg_->size () == 0) { state = body; - return dealer_session_t::push_msg (msg_); + return session_base_t::push_msg (msg_); } break; case body: if (msg_->flags () == msg_t::more) - return dealer_session_t::push_msg (msg_); + return session_base_t::push_msg (msg_); if (msg_->flags () == 0) { state = bottom; - return dealer_session_t::push_msg (msg_); + return session_base_t::push_msg (msg_); } break; } diff --git a/src/req.hpp b/src/req.hpp index 57216e03..fd187e23 100644 --- a/src/req.hpp +++ b/src/req.hpp @@ -58,7 +58,7 @@ namespace zmq const req_t &operator = (const req_t&); }; - class req_session_t : public dealer_session_t + class req_session_t : public session_base_t { public: diff --git a/src/router.cpp b/src/router.cpp index a5f56f2b..b9001414 100644 --- a/src/router.cpp +++ b/src/router.cpp @@ -406,15 +406,3 @@ bool zmq::router_t::identify_peer (pipe_t *pipe_) return true; } - -zmq::router_session_t::router_session_t (io_thread_t *io_thread_, bool connect_, - socket_base_t *socket_, const options_t &options_, - const address_t *addr_) : - session_base_t (io_thread_, connect_, socket_, options_, addr_) -{ -} - -zmq::router_session_t::~router_session_t () -{ -} - diff --git a/src/router.hpp b/src/router.hpp index a7e7ed9a..9b4e9e34 100644 --- a/src/router.hpp +++ b/src/router.hpp @@ -119,21 +119,6 @@ namespace zmq const router_t &operator = (const router_t&); }; - class router_session_t : public session_base_t - { - public: - - router_session_t (zmq::io_thread_t *io_thread_, bool connect_, - socket_base_t *socket_, const options_t &options_, - const address_t *addr_); - ~router_session_t (); - - private: - - router_session_t (const router_session_t&); - const router_session_t &operator = (const router_session_t&); - }; - } #endif diff --git a/src/session_base.cpp b/src/session_base.cpp index e658484b..302fec8a 100644 --- a/src/session_base.cpp +++ b/src/session_base.cpp @@ -30,17 +30,6 @@ #include "ctx.hpp" #include "req.hpp" -#include "dealer.hpp" -#include "rep.hpp" -#include "router.hpp" -#include "pub.hpp" -#include "xpub.hpp" -#include "sub.hpp" -#include "xsub.hpp" -#include "push.hpp" -#include "pull.hpp" -#include "pair.hpp" -#include "stream.hpp" zmq::session_base_t *zmq::session_base_t::create (class io_thread_t *io_thread_, bool connect_, class socket_base_t *socket_, const options_t &options_, @@ -53,47 +42,17 @@ zmq::session_base_t *zmq::session_base_t::create (class io_thread_t *io_thread_, socket_, options_, addr_); break; case ZMQ_DEALER: - s = new (std::nothrow) dealer_session_t (io_thread_, connect_, - socket_, options_, addr_); - break; case ZMQ_REP: - s = new (std::nothrow) rep_session_t (io_thread_, connect_, - socket_, options_, addr_); - break; case ZMQ_ROUTER: - s = new (std::nothrow) router_session_t (io_thread_, connect_, - socket_, options_, addr_); - break; case ZMQ_PUB: - s = new (std::nothrow) pub_session_t (io_thread_, connect_, - socket_, options_, addr_); - break; case ZMQ_XPUB: - s = new (std::nothrow) xpub_session_t (io_thread_, connect_, - socket_, options_, addr_); - break; case ZMQ_SUB: - s = new (std::nothrow) sub_session_t (io_thread_, connect_, - socket_, options_, addr_); - break; case ZMQ_XSUB: - s = new (std::nothrow) xsub_session_t (io_thread_, connect_, - socket_, options_, addr_); - break; case ZMQ_PUSH: - s = new (std::nothrow) push_session_t (io_thread_, connect_, - socket_, options_, addr_); - break; case ZMQ_PULL: - s = new (std::nothrow) pull_session_t (io_thread_, connect_, - socket_, options_, addr_); - break; case ZMQ_PAIR: - s = new (std::nothrow) pair_session_t (io_thread_, connect_, - socket_, options_, addr_); - break; case ZMQ_STREAM: - s = new (std::nothrow) stream_session_t (io_thread_, connect_, + s = new (std::nothrow) session_base_t (io_thread_, connect_, socket_, options_, addr_); break; default: diff --git a/src/stream.cpp b/src/stream.cpp index 0cb7e272..4b08b573 100644 --- a/src/stream.cpp +++ b/src/stream.cpp @@ -255,15 +255,3 @@ void zmq::stream_t::identify_peer (pipe_t *pipe_) outpipes_t::value_type (identity, outpipe)).second; zmq_assert (ok); } - -zmq::stream_session_t::stream_session_t (io_thread_t *io_thread_, bool connect_, - socket_base_t *socket_, const options_t &options_, - const address_t *addr_) : - session_base_t (io_thread_, connect_, socket_, options_, addr_) -{ -} - -zmq::stream_session_t::~stream_session_t () -{ -} - diff --git a/src/stream.hpp b/src/stream.hpp index 7c8def8a..ba5d921c 100644 --- a/src/stream.hpp +++ b/src/stream.hpp @@ -92,21 +92,6 @@ namespace zmq const stream_t &operator = (const stream_t&); }; - class stream_session_t : public session_base_t - { - public: - - stream_session_t (zmq::io_thread_t *io_thread_, bool connect_, - socket_base_t *socket_, const options_t &options_, - const address_t *addr_); - ~stream_session_t (); - - private: - - stream_session_t (const stream_session_t&); - const stream_session_t &operator = (const stream_session_t&); - }; - } #endif diff --git a/src/sub.cpp b/src/sub.cpp index 6e588f07..6edb7bb4 100644 --- a/src/sub.cpp +++ b/src/sub.cpp @@ -78,15 +78,3 @@ bool zmq::sub_t::xhas_out () // Overload the XSUB's send. return false; } - -zmq::sub_session_t::sub_session_t (io_thread_t *io_thread_, bool connect_, - socket_base_t *socket_, const options_t &options_, - const address_t *addr_) : - xsub_session_t (io_thread_, connect_, socket_, options_, addr_) -{ -} - -zmq::sub_session_t::~sub_session_t () -{ -} - diff --git a/src/sub.hpp b/src/sub.hpp index 33d3cef5..0a4df73d 100644 --- a/src/sub.hpp +++ b/src/sub.hpp @@ -49,21 +49,6 @@ namespace zmq const sub_t &operator = (const sub_t&); }; - class sub_session_t : public xsub_session_t - { - public: - - sub_session_t (zmq::io_thread_t *io_thread_, bool connect_, - zmq::socket_base_t *socket_, const options_t &options_, - const address_t *addr_); - ~sub_session_t (); - - private: - - sub_session_t (const sub_session_t&); - const sub_session_t &operator = (const sub_session_t&); - }; - } #endif diff --git a/src/xpub.cpp b/src/xpub.cpp index d3aee48e..fa07ef72 100644 --- a/src/xpub.cpp +++ b/src/xpub.cpp @@ -189,15 +189,3 @@ void zmq::xpub_t::send_unsubscription (unsigned char *data_, size_t size_, self->pending_flags.push_back (0); } } - -zmq::xpub_session_t::xpub_session_t (io_thread_t *io_thread_, bool connect_, - socket_base_t *socket_, const options_t &options_, - const address_t *addr_) : - session_base_t (io_thread_, connect_, socket_, options_, addr_) -{ -} - -zmq::xpub_session_t::~xpub_session_t () -{ -} - diff --git a/src/xpub.hpp b/src/xpub.hpp index 86f08f3a..d603c40b 100644 --- a/src/xpub.hpp +++ b/src/xpub.hpp @@ -89,21 +89,6 @@ namespace zmq const xpub_t &operator = (const xpub_t&); }; - class xpub_session_t : public session_base_t - { - public: - - xpub_session_t (zmq::io_thread_t *io_thread_, bool connect_, - socket_base_t *socket_, const options_t &options_, - const address_t *addr_); - ~xpub_session_t (); - - private: - - xpub_session_t (const xpub_session_t&); - const xpub_session_t &operator = (const xpub_session_t&); - }; - } #endif diff --git a/src/xsub.cpp b/src/xsub.cpp index e5e11f5b..a09c1367 100644 --- a/src/xsub.cpp +++ b/src/xsub.cpp @@ -226,15 +226,3 @@ void zmq::xsub_t::send_subscription (unsigned char *data_, size_t size_, if (!sent) msg.close (); } - -zmq::xsub_session_t::xsub_session_t (io_thread_t *io_thread_, bool connect_, - socket_base_t *socket_, const options_t &options_, - const address_t *addr_) : - session_base_t (io_thread_, connect_, socket_, options_, addr_) -{ -} - -zmq::xsub_session_t::~xsub_session_t () -{ -} - diff --git a/src/xsub.hpp b/src/xsub.hpp index 929299b5..bda727cc 100644 --- a/src/xsub.hpp +++ b/src/xsub.hpp @@ -86,21 +86,6 @@ namespace zmq const xsub_t &operator = (const xsub_t&); }; - class xsub_session_t : public session_base_t - { - public: - - xsub_session_t (class io_thread_t *io_thread_, bool connect_, - socket_base_t *socket_, const options_t &options_, - const address_t *addr_); - ~xsub_session_t (); - - private: - - xsub_session_t (const xsub_session_t&); - const xsub_session_t &operator = (const xsub_session_t&); - }; - } #endif