mirror of
https://github.com/zeromq/libzmq.git
synced 2025-01-19 00:46:05 +01:00
Use generic session class whenever possible
This commit is contained in:
parent
1beec5e960
commit
fd7e9b8c46
@ -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 ()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
12
src/pair.cpp
12
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 ()
|
||||
{
|
||||
}
|
||||
|
||||
|
15
src/pair.hpp
15
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
|
||||
|
12
src/pub.cpp
12
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 ()
|
||||
{
|
||||
}
|
||||
|
||||
|
15
src/pub.hpp
15
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
|
||||
|
12
src/pull.cpp
12
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 ()
|
||||
{
|
||||
}
|
||||
|
||||
|
15
src/pull.hpp
15
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
|
||||
|
12
src/push.cpp
12
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 ()
|
||||
{
|
||||
}
|
||||
|
||||
|
15
src/push.hpp
15
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
|
||||
|
12
src/rep.cpp
12
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 ()
|
||||
{
|
||||
}
|
||||
|
||||
|
15
src/rep.hpp
15
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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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:
|
||||
|
||||
|
@ -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 ()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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 ()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
12
src/sub.cpp
12
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 ()
|
||||
{
|
||||
}
|
||||
|
||||
|
15
src/sub.hpp
15
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
|
||||
|
12
src/xpub.cpp
12
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 ()
|
||||
{
|
||||
}
|
||||
|
||||
|
15
src/xpub.hpp
15
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
|
||||
|
12
src/xsub.cpp
12
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 ()
|
||||
{
|
||||
}
|
||||
|
||||
|
15
src/xsub.hpp
15
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user