From 628adf1cb73f0f42473ac337eb9b715d55fbc75c Mon Sep 17 00:00:00 2001 From: Simon Giesecke Date: Tue, 24 Dec 2019 10:39:26 +0100 Subject: [PATCH] Problem: inconsistent polymorphic inheritance Solution: consistently use virtual, override and final --- .clang-tidy | 4 +++ src/client.hpp | 20 +++++++------- src/ctx.hpp | 2 +- src/curve_client.hpp | 14 +++++----- src/curve_mechanism_base.hpp | 4 +-- src/curve_server.hpp | 14 +++++----- src/dealer.hpp | 22 ++++++++------- src/decoder.hpp | 10 +++---- src/devpoll.hpp | 6 ++-- src/dgram.hpp | 20 +++++++------- src/dish.hpp | 36 ++++++++++++------------ src/encoder.hpp | 8 ++---- src/epoll.hpp | 6 ++-- src/gather.hpp | 14 +++++----- src/gssapi_client.hpp | 14 +++++----- src/gssapi_mechanism_base.hpp | 2 +- src/gssapi_server.hpp | 17 ++++++------ src/io_object.hpp | 8 +++--- src/io_thread.hpp | 12 ++++---- src/ipc_connecter.hpp | 6 ++-- src/ipc_listener.hpp | 9 +++--- src/kqueue.hpp | 6 ++-- src/macros.hpp | 16 +++++++++++ src/mailbox.hpp | 10 +++---- src/mailbox_safe.hpp | 10 +++---- src/norm_engine.hpp | 18 ++++++------ src/null_mechanism.hpp | 12 ++++---- src/own.hpp | 12 ++++---- src/pair.hpp | 20 +++++++------- src/pgm_receiver.hpp | 2 +- src/pgm_sender.hpp | 2 +- src/pipe.hpp | 29 ++++++++++---------- src/plain_client.hpp | 10 +++---- src/plain_server.hpp | 8 +++--- src/poll.hpp | 4 +-- src/poller_base.cpp | 4 --- src/poller_base.hpp | 4 +-- src/pollset.hpp | 6 ++-- src/pub.hpp | 10 +++---- src/pull.hpp | 14 +++++----- src/push.hpp | 14 +++++----- src/radio.hpp | 33 +++++++++++----------- src/raw_decoder.hpp | 15 +++++----- src/raw_encoder.hpp | 4 +-- src/raw_engine.hpp | 10 +++---- src/reaper.hpp | 16 +++++------ src/rep.hpp | 12 ++++---- src/req.hpp | 25 +++++++++-------- src/router.hpp | 22 ++++++++------- src/scatter.hpp | 14 +++++----- src/select.hpp | 6 ++-- src/server.hpp | 20 +++++++------- src/session_base.hpp | 18 ++++++------ src/socket_base.hpp | 44 ++++++++++++++++-------------- src/socks_connecter.hpp | 10 +++---- src/stream.hpp | 21 +++++++------- src/stream_connecter_base.hpp | 10 +++---- src/stream_engine_base.hpp | 21 +++++++------- src/stream_listener_base.hpp | 6 ++-- src/sub.hpp | 11 ++++---- src/tcp_connecter.hpp | 12 ++++---- src/tcp_listener.hpp | 7 +++-- src/tipc_connecter.hpp | 6 ++-- src/tipc_listener.hpp | 7 +++-- src/udp_engine.hpp | 21 +++++++------- src/v1_decoder.hpp | 6 ++-- src/v1_encoder.hpp | 4 +-- src/v2_decoder.hpp | 6 ++-- src/v2_encoder.hpp | 4 +-- src/vmci_connecter.hpp | 2 +- src/vmci_listener.hpp | 2 +- src/ws_connecter.hpp | 14 +++++----- src/ws_decoder.hpp | 6 ++-- src/ws_encoder.hpp | 4 +-- src/ws_engine.hpp | 4 +-- src/ws_listener.hpp | 11 ++++---- src/xpub.hpp | 21 +++++++------- src/xsub.hpp | 24 ++++++++-------- src/ypipe.hpp | 14 +++++----- src/ypipe_conflate.hpp | 17 +++++++----- src/zap_client.hpp | 8 +++--- src/zmtp_engine.hpp | 16 +++++------ unittests/unittest_ip_resolver.cpp | 13 +++++---- unittests/unittest_poller.cpp | 6 ++-- 84 files changed, 525 insertions(+), 487 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index b136b173..5a7c53eb 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -420,3 +420,7 @@ CheckOptions: # value: '0' # - key: readability-simplify-boolean-expr.ChainedConditionalReturn # value: '0' + - key: modernize-use-override.OverrideSpelling + value: 'ZMQ_OVERRIDE' + - key: modernize-use-override.FinalSpelling + value: 'ZMQ_FINAL' diff --git a/src/client.hpp b/src/client.hpp index bee1916a..65723c31 100644 --- a/src/client.hpp +++ b/src/client.hpp @@ -41,24 +41,24 @@ class msg_t; class pipe_t; class io_thread_t; -class client_t : public socket_base_t +class client_t ZMQ_FINAL : public socket_base_t { public: client_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_); - ~client_t (); + ~client_t () ZMQ_FINAL; protected: // Overrides of functions from socket_base_t. void xattach_pipe (zmq::pipe_t *pipe_, bool subscribe_to_all_, - bool locally_initiated_); - int xsend (zmq::msg_t *msg_); - int xrecv (zmq::msg_t *msg_); - bool xhas_in (); - bool xhas_out (); - void xread_activated (zmq::pipe_t *pipe_); - void xwrite_activated (zmq::pipe_t *pipe_); - void xpipe_terminated (zmq::pipe_t *pipe_); + bool locally_initiated_) ZMQ_FINAL; + int xsend (zmq::msg_t *msg_) ZMQ_FINAL; + int xrecv (zmq::msg_t *msg_) ZMQ_FINAL; + bool xhas_in () ZMQ_FINAL; + bool xhas_out () ZMQ_FINAL; + void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL; + void xwrite_activated (zmq::pipe_t *pipe_) ZMQ_FINAL; + void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL; private: // Messages are fair-queued from inbound pipes. And load-balanced to diff --git a/src/ctx.hpp b/src/ctx.hpp index 3e76b707..593f9f70 100644 --- a/src/ctx.hpp +++ b/src/ctx.hpp @@ -90,7 +90,7 @@ class thread_ctx_t // Context object encapsulates all the global state associated with // the library. -class ctx_t : public thread_ctx_t +class ctx_t ZMQ_FINAL : public thread_ctx_t { public: // Create the context object. diff --git a/src/curve_client.hpp b/src/curve_client.hpp index c786e764..c85d1b78 100644 --- a/src/curve_client.hpp +++ b/src/curve_client.hpp @@ -41,18 +41,18 @@ namespace zmq class msg_t; class session_base_t; -class curve_client_t : public curve_mechanism_base_t +class curve_client_t ZMQ_FINAL : public curve_mechanism_base_t { public: curve_client_t (session_base_t *session_, const options_t &options_); - virtual ~curve_client_t (); + ~curve_client_t () ZMQ_FINAL; // mechanism implementation - virtual int next_handshake_command (msg_t *msg_); - virtual int process_handshake_command (msg_t *msg_); - virtual int encode (msg_t *msg_); - virtual int decode (msg_t *msg_); - virtual status_t status () const; + int next_handshake_command (msg_t *msg_) ZMQ_FINAL; + int process_handshake_command (msg_t *msg_) ZMQ_FINAL; + int encode (msg_t *msg_) ZMQ_FINAL; + int decode (msg_t *msg_) ZMQ_FINAL; + status_t status () const ZMQ_FINAL; private: enum state_t diff --git a/src/curve_mechanism_base.hpp b/src/curve_mechanism_base.hpp index 72b9b969..0b84f10c 100644 --- a/src/curve_mechanism_base.hpp +++ b/src/curve_mechanism_base.hpp @@ -61,8 +61,8 @@ class curve_mechanism_base_t : public virtual mechanism_base_t const char *decode_nonce_prefix_); // mechanism implementation - virtual int encode (msg_t *msg_); - virtual int decode (msg_t *msg_); + int encode (msg_t *msg_) ZMQ_OVERRIDE; + int decode (msg_t *msg_) ZMQ_OVERRIDE; protected: const char *encode_nonce_prefix; diff --git a/src/curve_server.hpp b/src/curve_server.hpp index b3d2dd73..2d0ec936 100644 --- a/src/curve_server.hpp +++ b/src/curve_server.hpp @@ -42,20 +42,20 @@ namespace zmq #pragma warning(push) #pragma warning(disable : 4250) #endif -class curve_server_t : public zap_client_common_handshake_t, - public curve_mechanism_base_t +class curve_server_t ZMQ_FINAL : public zap_client_common_handshake_t, + public curve_mechanism_base_t { public: curve_server_t (session_base_t *session_, const std::string &peer_address_, const options_t &options_); - virtual ~curve_server_t (); + ~curve_server_t () ZMQ_FINAL; // mechanism implementation - virtual int next_handshake_command (msg_t *msg_); - virtual int process_handshake_command (msg_t *msg_); - virtual int encode (msg_t *msg_); - virtual int decode (msg_t *msg_); + int next_handshake_command (msg_t *msg_) ZMQ_FINAL; + int process_handshake_command (msg_t *msg_) ZMQ_FINAL; + int encode (msg_t *msg_) ZMQ_FINAL; + int decode (msg_t *msg_) ZMQ_FINAL; private: // Our secret key (s) diff --git a/src/dealer.hpp b/src/dealer.hpp index 98097b02..5515fd39 100644 --- a/src/dealer.hpp +++ b/src/dealer.hpp @@ -47,21 +47,23 @@ class dealer_t : public socket_base_t { public: dealer_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_); - ~dealer_t (); + ~dealer_t () ZMQ_OVERRIDE; protected: // Overrides of functions from socket_base_t. void xattach_pipe (zmq::pipe_t *pipe_, bool subscribe_to_all_, - bool locally_initiated_); - int xsetsockopt (int option_, const void *optval_, size_t optvallen_); - int xsend (zmq::msg_t *msg_); - int xrecv (zmq::msg_t *msg_); - bool xhas_in (); - bool xhas_out (); - void xread_activated (zmq::pipe_t *pipe_); - void xwrite_activated (zmq::pipe_t *pipe_); - void xpipe_terminated (zmq::pipe_t *pipe_); + bool locally_initiated_) ZMQ_FINAL; + int xsetsockopt (int option_, + const void *optval_, + size_t optvallen_) ZMQ_OVERRIDE; + int xsend (zmq::msg_t *msg_) ZMQ_OVERRIDE; + int xrecv (zmq::msg_t *msg_) ZMQ_OVERRIDE; + bool xhas_in () ZMQ_OVERRIDE; + bool xhas_out () ZMQ_OVERRIDE; + void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL; + void xwrite_activated (zmq::pipe_t *pipe_) ZMQ_FINAL; + void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_OVERRIDE; // Send and recv - knowing which pipe was used. int sendpipe (zmq::msg_t *msg_, zmq::pipe_t **pipe_); diff --git a/src/decoder.hpp b/src/decoder.hpp index 3dcbb1fe..a2cd5a99 100644 --- a/src/decoder.hpp +++ b/src/decoder.hpp @@ -66,12 +66,10 @@ class decoder_base_t : public i_decoder _buf = _allocator.allocate (); } - // The destructor doesn't have to be virtual. It is made virtual - // just to keep ICC and code checking tools from complaining. - virtual ~decoder_base_t () { _allocator.deallocate (); } + ~decoder_base_t () ZMQ_OVERRIDE { _allocator.deallocate (); } // Returns a buffer to be filled with binary data. - void get_buffer (unsigned char **data_, std::size_t *size_) + void get_buffer (unsigned char **data_, std::size_t *size_) ZMQ_FINAL { _buf = _allocator.allocate (); @@ -101,7 +99,7 @@ class decoder_base_t : public i_decoder // Number of bytes processed is returned in bytes_used_. int decode (const unsigned char *data_, std::size_t size_, - std::size_t &bytes_used_) + std::size_t &bytes_used_) ZMQ_FINAL { bytes_used_ = 0; @@ -149,7 +147,7 @@ class decoder_base_t : public i_decoder return 0; } - virtual void resize_buffer (std::size_t new_size_) + void resize_buffer (std::size_t new_size_) ZMQ_FINAL { _allocator.resize (new_size_); } diff --git a/src/devpoll.hpp b/src/devpoll.hpp index 733ec4d4..e57814b9 100644 --- a/src/devpoll.hpp +++ b/src/devpoll.hpp @@ -47,13 +47,13 @@ struct i_poll_events; // Implements socket polling mechanism using the "/dev/poll" interface. -class devpoll_t : public worker_poller_base_t +class devpoll_t ZMQ_FINAL : public worker_poller_base_t { public: typedef fd_t handle_t; devpoll_t (const thread_ctx_t &ctx_); - ~devpoll_t (); + ~devpoll_t () ZMQ_FINAL; // "poller" concept. handle_t add_fd (fd_t fd_, zmq::i_poll_events *events_); @@ -68,7 +68,7 @@ class devpoll_t : public worker_poller_base_t private: // Main event loop. - void loop (); + void loop () ZMQ_FINAL; // File descriptor referring to "/dev/poll" pseudo-device. fd_t devpoll_fd; diff --git a/src/dgram.hpp b/src/dgram.hpp index 40bba774..b819d127 100644 --- a/src/dgram.hpp +++ b/src/dgram.hpp @@ -41,23 +41,23 @@ class msg_t; class pipe_t; class io_thread_t; -class dgram_t : public socket_base_t +class dgram_t ZMQ_FINAL : public socket_base_t { public: dgram_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_); - ~dgram_t (); + ~dgram_t () ZMQ_FINAL; // Overrides of functions from socket_base_t. void xattach_pipe (zmq::pipe_t *pipe_, bool subscribe_to_all_, - bool locally_initiated_); - int xsend (zmq::msg_t *msg_); - int xrecv (zmq::msg_t *msg_); - bool xhas_in (); - bool xhas_out (); - void xread_activated (zmq::pipe_t *pipe_); - void xwrite_activated (zmq::pipe_t *pipe_); - void xpipe_terminated (zmq::pipe_t *pipe_); + bool locally_initiated_) ZMQ_FINAL; + int xsend (zmq::msg_t *msg_) ZMQ_FINAL; + int xrecv (zmq::msg_t *msg_) ZMQ_FINAL; + bool xhas_in () ZMQ_FINAL; + bool xhas_out () ZMQ_FINAL; + void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL; + void xwrite_activated (zmq::pipe_t *pipe_) ZMQ_FINAL; + void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL; private: zmq::pipe_t *_pipe; diff --git a/src/dish.hpp b/src/dish.hpp index 929a19ee..c0986449 100644 --- a/src/dish.hpp +++ b/src/dish.hpp @@ -44,27 +44,27 @@ class ctx_t; class pipe_t; class io_thread_t; -class dish_t : public socket_base_t +class dish_t ZMQ_FINAL : public socket_base_t { public: dish_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_); - ~dish_t (); + ~dish_t () ZMQ_FINAL; protected: // Overrides of functions from socket_base_t. void xattach_pipe (zmq::pipe_t *pipe_, bool subscribe_to_all_, - bool locally_initiated_); - int xsend (zmq::msg_t *msg_); - bool xhas_out (); - int xrecv (zmq::msg_t *msg_); - bool xhas_in (); - void xread_activated (zmq::pipe_t *pipe_); - void xwrite_activated (zmq::pipe_t *pipe_); - void xhiccuped (pipe_t *pipe_); - void xpipe_terminated (zmq::pipe_t *pipe_); - int xjoin (const char *group_); - int xleave (const char *group_); + bool locally_initiated_) ZMQ_FINAL; + int xsend (zmq::msg_t *msg_) ZMQ_FINAL; + bool xhas_out () ZMQ_FINAL; + int xrecv (zmq::msg_t *msg_) ZMQ_FINAL; + bool xhas_in () ZMQ_FINAL; + void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL; + void xwrite_activated (zmq::pipe_t *pipe_) ZMQ_FINAL; + void xhiccuped (pipe_t *pipe_) ZMQ_FINAL; + void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL; + int xjoin (const char *group_) ZMQ_FINAL; + int xleave (const char *group_) ZMQ_FINAL; private: int xxrecv (zmq::msg_t *msg_); @@ -90,7 +90,7 @@ class dish_t : public socket_base_t ZMQ_NON_COPYABLE_NOR_MOVABLE (dish_t) }; -class dish_session_t : public session_base_t +class dish_session_t ZMQ_FINAL : public session_base_t { public: dish_session_t (zmq::io_thread_t *io_thread_, @@ -98,12 +98,12 @@ class dish_session_t : public session_base_t zmq::socket_base_t *socket_, const options_t &options_, address_t *addr_); - ~dish_session_t (); + ~dish_session_t () ZMQ_FINAL; // Overrides of the functions from session_base_t. - int push_msg (msg_t *msg_); - int pull_msg (msg_t *msg_); - void reset (); + int push_msg (msg_t *msg_) ZMQ_FINAL; + int pull_msg (msg_t *msg_) ZMQ_FINAL; + void reset () ZMQ_FINAL; private: enum diff --git a/src/encoder.hpp b/src/encoder.hpp index 9359b9ce..ce65d69c 100644 --- a/src/encoder.hpp +++ b/src/encoder.hpp @@ -66,14 +66,12 @@ template class encoder_base_t : public i_encoder alloc_assert (_buf); } - // The destructor doesn't have to be virtual. It is made virtual - // just to keep ICC and code checking tools from complaining. - inline virtual ~encoder_base_t () { free (_buf); } + inline ~encoder_base_t () ZMQ_OVERRIDE { free (_buf); } // The function returns a batch of binary data. The data // are filled to a supplied buffer. If no buffer is supplied (data_ // points to NULL) decoder object will provide buffer of its own. - inline size_t encode (unsigned char **data_, size_t size_) + inline size_t encode (unsigned char **data_, size_t size_) ZMQ_FINAL { unsigned char *buffer = !*data_ ? _buf : *data_; size_t buffersize = !*data_ ? _buf_size : size_; @@ -128,7 +126,7 @@ template class encoder_base_t : public i_encoder return pos; } - void load_msg (msg_t *msg_) + void load_msg (msg_t *msg_) ZMQ_FINAL { zmq_assert (in_progress () == NULL); _in_progress = msg_; diff --git a/src/epoll.hpp b/src/epoll.hpp index 548d36c8..6ace0003 100644 --- a/src/epoll.hpp +++ b/src/epoll.hpp @@ -55,13 +55,13 @@ struct i_poll_events; // This class implements socket polling mechanism using the Linux-specific // epoll mechanism. -class epoll_t : public worker_poller_base_t +class epoll_t ZMQ_FINAL : public worker_poller_base_t { public: typedef void *handle_t; epoll_t (const thread_ctx_t &ctx_); - ~epoll_t (); + ~epoll_t () ZMQ_OVERRIDE; // "poller" concept. handle_t add_fd (fd_t fd_, zmq::i_poll_events *events_); @@ -87,7 +87,7 @@ class epoll_t : public worker_poller_base_t #endif // Main event loop. - void loop (); + void loop () ZMQ_FINAL; // Main epoll file descriptor epoll_fd_t _epoll_fd; diff --git a/src/gather.hpp b/src/gather.hpp index 3edbdc78..7dcab48c 100644 --- a/src/gather.hpp +++ b/src/gather.hpp @@ -39,21 +39,21 @@ class ctx_t; class pipe_t; class msg_t; -class gather_t : public socket_base_t +class gather_t ZMQ_FINAL : public socket_base_t { public: gather_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_); - ~gather_t (); + ~gather_t () ZMQ_FINAL; protected: // Overrides of functions from socket_base_t. void xattach_pipe (zmq::pipe_t *pipe_, bool subscribe_to_all_, - bool locally_initiated_); - int xrecv (zmq::msg_t *msg_); - bool xhas_in (); - void xread_activated (zmq::pipe_t *pipe_); - void xpipe_terminated (zmq::pipe_t *pipe_); + bool locally_initiated_) ZMQ_FINAL; + int xrecv (zmq::msg_t *msg_) ZMQ_FINAL; + bool xhas_in () ZMQ_FINAL; + void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL; + void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL; private: // Fair queueing object for inbound pipes. diff --git a/src/gssapi_client.hpp b/src/gssapi_client.hpp index 02d72fc9..18d428c8 100644 --- a/src/gssapi_client.hpp +++ b/src/gssapi_client.hpp @@ -39,18 +39,18 @@ namespace zmq class msg_t; class session_base_t; -class gssapi_client_t : public gssapi_mechanism_base_t +class gssapi_client_t ZMQ_FINAL : public gssapi_mechanism_base_t { public: gssapi_client_t (session_base_t *session_, const options_t &options_); - virtual ~gssapi_client_t (); + ~gssapi_client_t () ZMQ_FINAL; // mechanism implementation - virtual int next_handshake_command (msg_t *msg_); - virtual int process_handshake_command (msg_t *msg_); - virtual int encode (msg_t *msg_); - virtual int decode (msg_t *msg_); - virtual status_t status () const; + int next_handshake_command (msg_t *msg_) ZMQ_FINAL; + int process_handshake_command (msg_t *msg_) ZMQ_FINAL; + int encode (msg_t *msg_) ZMQ_FINAL; + int decode (msg_t *msg_) ZMQ_FINAL; + status_t status () const ZMQ_FINAL; private: enum state_t diff --git a/src/gssapi_mechanism_base.hpp b/src/gssapi_mechanism_base.hpp index 4e14809c..dec53d0b 100644 --- a/src/gssapi_mechanism_base.hpp +++ b/src/gssapi_mechanism_base.hpp @@ -53,7 +53,7 @@ class gssapi_mechanism_base_t : public virtual mechanism_base_t public: gssapi_mechanism_base_t (session_base_t *session_, const options_t &options_); - virtual ~gssapi_mechanism_base_t () = 0; + ~gssapi_mechanism_base_t () ZMQ_OVERRIDE = 0; protected: // Produce a context-level GSSAPI token (INITIATE command) diff --git a/src/gssapi_server.hpp b/src/gssapi_server.hpp index d4a0dd93..26130115 100644 --- a/src/gssapi_server.hpp +++ b/src/gssapi_server.hpp @@ -40,21 +40,22 @@ namespace zmq class msg_t; class session_base_t; -class gssapi_server_t : public gssapi_mechanism_base_t, public zap_client_t +class gssapi_server_t ZMQ_FINAL : public gssapi_mechanism_base_t, + public zap_client_t { public: gssapi_server_t (session_base_t *session_, const std::string &peer_address, const options_t &options_); - virtual ~gssapi_server_t (); + ~gssapi_server_t () ZMQ_FINAL; // mechanism implementation - virtual int next_handshake_command (msg_t *msg_); - virtual int process_handshake_command (msg_t *msg_); - virtual int encode (msg_t *msg_); - virtual int decode (msg_t *msg_); - virtual int zap_msg_available (); - virtual status_t status () const; + int next_handshake_command (msg_t *msg_) ZMQ_FINAL; + int process_handshake_command (msg_t *msg_) ZMQ_FINAL; + int encode (msg_t *msg_) ZMQ_FINAL; + int decode (msg_t *msg_) ZMQ_FINAL; + int zap_msg_available () ZMQ_FINAL; + status_t status () const ZMQ_FINAL; private: enum state_t diff --git a/src/io_object.hpp b/src/io_object.hpp index 50ead7ed..703af7ef 100644 --- a/src/io_object.hpp +++ b/src/io_object.hpp @@ -48,7 +48,7 @@ class io_object_t : public i_poll_events { public: io_object_t (zmq::io_thread_t *io_thread_ = NULL); - ~io_object_t (); + ~io_object_t () ZMQ_OVERRIDE; // When migrating an object from one I/O thread to another, first // unplug it, then migrate it, then plug it to the new thread. @@ -69,9 +69,9 @@ class io_object_t : public i_poll_events void cancel_timer (int id_); // i_poll_events interface implementation. - void in_event (); - void out_event (); - void timer_event (int id_); + void in_event () ZMQ_OVERRIDE; + void out_event () ZMQ_OVERRIDE; + void timer_event (int id_) ZMQ_OVERRIDE; private: poller_t *_poller; diff --git a/src/io_thread.hpp b/src/io_thread.hpp index d6a598a7..98552e15 100644 --- a/src/io_thread.hpp +++ b/src/io_thread.hpp @@ -43,14 +43,14 @@ class ctx_t; // Generic part of the I/O thread. Polling-mechanism-specific features // are implemented in separate "polling objects". -class io_thread_t : public object_t, public i_poll_events +class io_thread_t ZMQ_FINAL : public object_t, public i_poll_events { public: io_thread_t (zmq::ctx_t *ctx_, uint32_t tid_); // Clean-up. If the thread was started, it's necessary to call 'stop' // before invoking destructor. Otherwise the destructor would hang up. - ~io_thread_t (); + ~io_thread_t () ZMQ_FINAL; // Launch the physical thread. void start (); @@ -62,15 +62,15 @@ class io_thread_t : public object_t, public i_poll_events mailbox_t *get_mailbox (); // i_poll_events implementation. - void in_event (); - void out_event (); - void timer_event (int id_); + void in_event () ZMQ_FINAL; + void out_event () ZMQ_FINAL; + void timer_event (int id_) ZMQ_FINAL; // Used by io_objects to retrieve the associated poller object. poller_t *get_poller (); // Command handlers. - void process_stop (); + void process_stop () ZMQ_FINAL; // Returns load experienced by the I/O thread. int get_load (); diff --git a/src/ipc_connecter.hpp b/src/ipc_connecter.hpp index 4d727220..df09c51f 100644 --- a/src/ipc_connecter.hpp +++ b/src/ipc_connecter.hpp @@ -37,7 +37,7 @@ namespace zmq { -class ipc_connecter_t : public stream_connecter_base_t +class ipc_connecter_t ZMQ_FINAL : public stream_connecter_base_t { public: // If 'delayed_start' is true connecter first waits for a while, @@ -50,10 +50,10 @@ class ipc_connecter_t : public stream_connecter_base_t private: // Handlers for I/O events. - void out_event (); + void out_event () ZMQ_FINAL; // Internal function to start the actual connection establishment. - void start_connecting (); + void start_connecting () ZMQ_FINAL; // Open IPC connecting socket. Returns -1 in case of error, // 0 if connect was successful immediately. Returns -1 with diff --git a/src/ipc_listener.hpp b/src/ipc_listener.hpp index 969e33ec..2281549f 100644 --- a/src/ipc_listener.hpp +++ b/src/ipc_listener.hpp @@ -39,7 +39,7 @@ namespace zmq { -class ipc_listener_t : public stream_listener_base_t +class ipc_listener_t ZMQ_FINAL : public stream_listener_base_t { public: ipc_listener_t (zmq::io_thread_t *io_thread_, @@ -50,11 +50,12 @@ class ipc_listener_t : public stream_listener_base_t int set_local_address (const char *addr_); protected: - std::string get_socket_name (fd_t fd_, socket_end_t socket_end_) const; + std::string get_socket_name (fd_t fd_, + socket_end_t socket_end_) const ZMQ_FINAL; private: // Handlers for I/O events. - void in_event (); + void in_event () ZMQ_FINAL; // Filter new connections if the OS provides a mechanism to get // the credentials of the peer process. Called from accept(). @@ -62,7 +63,7 @@ class ipc_listener_t : public stream_listener_base_t bool filter (fd_t sock_); #endif - int close (); + int close () ZMQ_FINAL; // Accept the new connection. Returns the file descriptor of the // newly created connection. The function may return retired_fd diff --git a/src/kqueue.hpp b/src/kqueue.hpp index f51596c9..002fbab3 100644 --- a/src/kqueue.hpp +++ b/src/kqueue.hpp @@ -49,13 +49,13 @@ struct i_poll_events; // Implements socket polling mechanism using the BSD-specific // kqueue interface. -class kqueue_t : public worker_poller_base_t +class kqueue_t ZMQ_FINAL : public worker_poller_base_t { public: typedef void *handle_t; kqueue_t (const thread_ctx_t &ctx_); - ~kqueue_t (); + ~kqueue_t () ZMQ_FINAL; // "poller" concept. handle_t add_fd (fd_t fd_, zmq::i_poll_events *events_); @@ -70,7 +70,7 @@ class kqueue_t : public worker_poller_base_t private: // Main event loop. - void loop (); + void loop () ZMQ_FINAL; // File descriptor referring to the kernel event queue. fd_t kqueue_fd; diff --git a/src/macros.hpp b/src/macros.hpp index 93cf30a1..427a9e25 100644 --- a/src/macros.hpp +++ b/src/macros.hpp @@ -20,6 +20,22 @@ #endif #endif +#if !defined ZMQ_OVERRIDE +#if defined ZMQ_HAVE_NOEXCEPT +#define ZMQ_OVERRIDE override +#else +#define ZMQ_OVERRIDE +#endif +#endif + +#if !defined ZMQ_FINAL +#if defined ZMQ_HAVE_NOEXCEPT +#define ZMQ_FINAL final +#else +#define ZMQ_FINAL +#endif +#endif + #if !defined ZMQ_DEFAULT #if defined ZMQ_HAVE_NOEXCEPT #define ZMQ_DEFAULT = default; diff --git a/src/mailbox.hpp b/src/mailbox.hpp index fe945924..80556b47 100644 --- a/src/mailbox.hpp +++ b/src/mailbox.hpp @@ -42,15 +42,15 @@ namespace zmq { -class mailbox_t : public i_mailbox +class mailbox_t ZMQ_FINAL : public i_mailbox { public: mailbox_t (); - ~mailbox_t (); + ~mailbox_t () ZMQ_FINAL; fd_t get_fd () const; - void send (const command_t &cmd_); - int recv (command_t *cmd_, int timeout_); + void send (const command_t &cmd_) ZMQ_FINAL; + int recv (command_t *cmd_, int timeout_) ZMQ_FINAL; bool valid () const; @@ -58,7 +58,7 @@ class mailbox_t : public i_mailbox // close the file descriptors in the signaller. This is used in a forked // child process to close the file descriptors so that they do not interfere // with the context in the parent process. - void forked () { _signaler.forked (); } + void forked () ZMQ_FINAL { _signaler.forked (); } #endif private: diff --git a/src/mailbox_safe.hpp b/src/mailbox_safe.hpp index 580f02f6..4c7a9807 100644 --- a/src/mailbox_safe.hpp +++ b/src/mailbox_safe.hpp @@ -44,14 +44,14 @@ namespace zmq { -class mailbox_safe_t : public i_mailbox +class mailbox_safe_t ZMQ_FINAL : public i_mailbox { public: mailbox_safe_t (mutex_t *sync_); - ~mailbox_safe_t (); + ~mailbox_safe_t () ZMQ_FINAL; - void send (const command_t &cmd_); - int recv (command_t *cmd_, int timeout_); + void send (const command_t &cmd_) ZMQ_FINAL; + int recv (command_t *cmd_, int timeout_) ZMQ_FINAL; // Add signaler to mailbox which will be called when a message is ready void add_signaler (signaler_t *signaler_); @@ -62,7 +62,7 @@ class mailbox_safe_t : public i_mailbox // close the file descriptors in the signaller. This is used in a forked // child process to close the file descriptors so that they do not interfere // with the context in the parent process. - void forked () + void forked () ZMQ_FINAL { // TODO: call fork on the condition variable } diff --git a/src/norm_engine.hpp b/src/norm_engine.hpp index 46adcaf9..f4007a99 100644 --- a/src/norm_engine.hpp +++ b/src/norm_engine.hpp @@ -18,11 +18,11 @@ class io_thread_t; class msg_t; class session_base_t; -class norm_engine_t : public io_object_t, public i_engine +class norm_engine_t ZMQ_FINAL : public io_object_t, public i_engine { public: norm_engine_t (zmq::io_thread_t *parent_, const options_t &options_); - ~norm_engine_t (); + ~norm_engine_t () ZMQ_FINAL; // create NORM instance, session, etc int init (const char *network_, bool send, bool recv); @@ -30,24 +30,24 @@ class norm_engine_t : public io_object_t, public i_engine // i_engine interface implementation. // Plug the engine to the session. - virtual void plug (zmq::io_thread_t *io_thread_, - class session_base_t *session_); + void plug (zmq::io_thread_t *io_thread_, + class session_base_t *session_) ZMQ_FINAL; // Terminate and deallocate the engine. Note that 'detached' // events are not fired on termination. - virtual void terminate (); + void terminate () ZMQ_FINAL; // This method is called by the session to signalise that more // messages can be written to the pipe. - virtual bool restart_input (); + bool restart_input () ZMQ_FINAL; // This method is called by the session to signalise that there // are messages to send available. - virtual void restart_output (); + void restart_output () ZMQ_FINAL; - virtual void zap_msg_available (){}; + void zap_msg_available () ZMQ_FINAL {} - virtual const endpoint_uri_pair_t &get_endpoint () const; + const endpoint_uri_pair_t &get_endpoint () const ZMQ_FINAL; // i_poll_events interface implementation. // (we only need in_event() for NormEvent notification) diff --git a/src/null_mechanism.hpp b/src/null_mechanism.hpp index b3f32c55..7e85b504 100644 --- a/src/null_mechanism.hpp +++ b/src/null_mechanism.hpp @@ -39,19 +39,19 @@ namespace zmq class msg_t; class session_base_t; -class null_mechanism_t : public zap_client_t +class null_mechanism_t ZMQ_FINAL : public zap_client_t { public: null_mechanism_t (session_base_t *session_, const std::string &peer_address_, const options_t &options_); - virtual ~null_mechanism_t (); + ~null_mechanism_t () ZMQ_FINAL; // mechanism implementation - virtual int next_handshake_command (msg_t *msg_); - virtual int process_handshake_command (msg_t *msg_); - virtual int zap_msg_available (); - virtual status_t status () const; + int next_handshake_command (msg_t *msg_) ZMQ_FINAL; + int process_handshake_command (msg_t *msg_) ZMQ_FINAL; + int zap_msg_available () ZMQ_FINAL; + status_t status () const ZMQ_FINAL; private: bool _ready_command_sent; diff --git a/src/own.hpp b/src/own.hpp index 98e342ac..25fe5a6d 100644 --- a/src/own.hpp +++ b/src/own.hpp @@ -90,12 +90,12 @@ class own_t : public object_t // others to invoke the destructor. At the same time, it has to be // virtual so that generic own_t deallocation mechanism destroys // specific type of the owned object correctly. - virtual ~own_t (); + ~own_t () ZMQ_OVERRIDE; // Term handler is protected rather than private so that it can // be intercepted by the derived class. This is useful to add custom // steps to the beginning of the termination process. - void process_term (int linger_); + void process_term (int linger_) ZMQ_OVERRIDE; // A place to hook in when physical destruction of the object // is to be delayed. @@ -109,10 +109,10 @@ class own_t : public object_t void set_owner (own_t *owner_); // Handlers for incoming commands. - void process_own (own_t *object_); - void process_term_req (own_t *object_); - void process_term_ack (); - void process_seqnum (); + void process_own (own_t *object_) ZMQ_OVERRIDE; + void process_term_req (own_t *object_) ZMQ_OVERRIDE; + void process_term_ack () ZMQ_OVERRIDE; + void process_seqnum () ZMQ_OVERRIDE; // Check whether all the pending term acks were delivered. // If so, deallocate this object. diff --git a/src/pair.hpp b/src/pair.hpp index 02dcaf84..4e60ec13 100644 --- a/src/pair.hpp +++ b/src/pair.hpp @@ -41,23 +41,23 @@ class msg_t; class pipe_t; class io_thread_t; -class pair_t : public socket_base_t +class pair_t ZMQ_FINAL : public socket_base_t { public: pair_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_); - ~pair_t (); + ~pair_t () ZMQ_FINAL; // Overrides of functions from socket_base_t. void xattach_pipe (zmq::pipe_t *pipe_, bool subscribe_to_all_, - bool locally_initiated_); - int xsend (zmq::msg_t *msg_); - int xrecv (zmq::msg_t *msg_); - bool xhas_in (); - bool xhas_out (); - void xread_activated (zmq::pipe_t *pipe_); - void xwrite_activated (zmq::pipe_t *pipe_); - void xpipe_terminated (zmq::pipe_t *pipe_); + bool locally_initiated_) ZMQ_FINAL; + int xsend (zmq::msg_t *msg_) ZMQ_FINAL; + int xrecv (zmq::msg_t *msg_) ZMQ_FINAL; + bool xhas_in () ZMQ_FINAL; + bool xhas_out () ZMQ_FINAL; + void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL; + void xwrite_activated (zmq::pipe_t *pipe_) ZMQ_FINAL; + void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL; private: zmq::pipe_t *_pipe; diff --git a/src/pgm_receiver.hpp b/src/pgm_receiver.hpp index 64c74744..8e5e9991 100644 --- a/src/pgm_receiver.hpp +++ b/src/pgm_receiver.hpp @@ -46,7 +46,7 @@ namespace zmq class io_thread_t; class session_base_t; -class pgm_receiver_t : public io_object_t, public i_engine +class pgm_receiver_t ZMQ_FINAL : public io_object_t, public i_engine { public: pgm_receiver_t (zmq::io_thread_t *parent_, const options_t &options_); diff --git a/src/pgm_sender.hpp b/src/pgm_sender.hpp index a3d23a27..a2a04383 100644 --- a/src/pgm_sender.hpp +++ b/src/pgm_sender.hpp @@ -45,7 +45,7 @@ namespace zmq class io_thread_t; class session_base_t; -class pgm_sender_t : public io_object_t, public i_engine +class pgm_sender_t ZMQ_FINAL : public io_object_t, public i_engine { public: pgm_sender_t (zmq::io_thread_t *parent_, const options_t &options_); diff --git a/src/pipe.hpp b/src/pipe.hpp index 3f894e8c..9453c98c 100644 --- a/src/pipe.hpp +++ b/src/pipe.hpp @@ -71,10 +71,10 @@ struct i_pipe_events // The array of inbound pipes (1), the array of outbound pipes (2) and // the generic array of pipes to be deallocated (3). -class pipe_t : public object_t, - public array_item_t<1>, - public array_item_t<2>, - public array_item_t<3> +class pipe_t ZMQ_FINAL : public object_t, + public array_item_t<1>, + public array_item_t<2>, + public array_item_t<3> { // This allows pipepair to create pipe objects. friend int pipepair (zmq::object_t *parents_[2], @@ -152,15 +152,16 @@ class pipe_t : public object_t, typedef ypipe_base_t upipe_t; // Command handlers. - void process_activate_read (); - void process_activate_write (uint64_t msgs_read_); - void process_hiccup (void *pipe_); - void process_pipe_peer_stats (uint64_t queue_count_, - own_t *socket_base_, - endpoint_uri_pair_t *endpoint_pair_); - void process_pipe_term (); - void process_pipe_term_ack (); - void process_pipe_hwm (int inhwm_, int outhwm_); + void process_activate_read () ZMQ_OVERRIDE; + void process_activate_write (uint64_t msgs_read_) ZMQ_OVERRIDE; + void process_hiccup (void *pipe_) ZMQ_OVERRIDE; + void + process_pipe_peer_stats (uint64_t queue_count_, + own_t *socket_base_, + endpoint_uri_pair_t *endpoint_pair_) ZMQ_OVERRIDE; + void process_pipe_term () ZMQ_OVERRIDE; + void process_pipe_term_ack () ZMQ_OVERRIDE; + void process_pipe_hwm (int inhwm_, int outhwm_) ZMQ_OVERRIDE; // Handler for delimiter read from the pipe. void process_delimiter (); @@ -179,7 +180,7 @@ class pipe_t : public object_t, void set_peer (pipe_t *peer_); // Destructor is private. Pipe objects destroy themselves. - ~pipe_t (); + ~pipe_t () ZMQ_OVERRIDE; // Underlying pipes for both directions. upipe_t *_in_pipe; diff --git a/src/plain_client.hpp b/src/plain_client.hpp index 70cb728e..76d91ae3 100644 --- a/src/plain_client.hpp +++ b/src/plain_client.hpp @@ -37,16 +37,16 @@ namespace zmq { class msg_t; -class plain_client_t : public mechanism_base_t +class plain_client_t ZMQ_FINAL : public mechanism_base_t { public: plain_client_t (session_base_t *const session_, const options_t &options_); - virtual ~plain_client_t (); + ~plain_client_t () ZMQ_FINAL; // mechanism implementation - virtual int next_handshake_command (msg_t *msg_); - virtual int process_handshake_command (msg_t *msg_); - virtual status_t status () const; + int next_handshake_command (msg_t *msg_) ZMQ_FINAL; + int process_handshake_command (msg_t *msg_) ZMQ_FINAL; + status_t status () const ZMQ_FINAL; private: enum state_t diff --git a/src/plain_server.hpp b/src/plain_server.hpp index 29c3a6d6..19d3c827 100644 --- a/src/plain_server.hpp +++ b/src/plain_server.hpp @@ -38,17 +38,17 @@ namespace zmq class msg_t; class session_base_t; -class plain_server_t : public zap_client_common_handshake_t +class plain_server_t ZMQ_FINAL : public zap_client_common_handshake_t { public: plain_server_t (session_base_t *session_, const std::string &peer_address_, const options_t &options_); - virtual ~plain_server_t (); + ~plain_server_t () ZMQ_FINAL; // mechanism implementation - virtual int next_handshake_command (msg_t *msg_); - virtual int process_handshake_command (msg_t *msg_); + int next_handshake_command (msg_t *msg_) ZMQ_FINAL; + int process_handshake_command (msg_t *msg_) ZMQ_FINAL; private: void produce_welcome (msg_t *msg_) const; diff --git a/src/poll.hpp b/src/poll.hpp index 628ceae0..4c274425 100644 --- a/src/poll.hpp +++ b/src/poll.hpp @@ -56,7 +56,7 @@ struct i_poll_events; // Implements socket polling mechanism using the POSIX.1-2001 // poll() system call. -class poll_t : public worker_poller_base_t +class poll_t ZMQ_FINAL : public worker_poller_base_t { public: typedef fd_t handle_t; @@ -78,7 +78,7 @@ class poll_t : public worker_poller_base_t private: // Main event loop. - virtual void loop (); + void loop () ZMQ_FINAL; void cleanup_retired (); diff --git a/src/poller_base.cpp b/src/poller_base.cpp index db38b910..b81bd6c5 100644 --- a/src/poller_base.cpp +++ b/src/poller_base.cpp @@ -32,10 +32,6 @@ #include "i_poll_events.hpp" #include "err.hpp" -zmq::poller_base_t::poller_base_t () -{ -} - zmq::poller_base_t::~poller_base_t () { // Make sure there is no more load on the shutdown. diff --git a/src/poller_base.hpp b/src/poller_base.hpp index d5f2fef2..d167d797 100644 --- a/src/poller_base.hpp +++ b/src/poller_base.hpp @@ -114,7 +114,7 @@ struct i_poll_events; // a container that is being iterated by the poller. -// A class that can be used as a base class for implementations of the poller +// A class that can be used as abase class for implementations of the poller // concept. // // For documentation of the public methods, see the description of the poller_t @@ -122,7 +122,7 @@ struct i_poll_events; class poller_base_t { public: - poller_base_t (); + poller_base_t () ZMQ_DEFAULT; virtual ~poller_base_t (); // Methods from the poller concept. diff --git a/src/pollset.hpp b/src/pollset.hpp index 66a003ff..8286bed2 100644 --- a/src/pollset.hpp +++ b/src/pollset.hpp @@ -50,13 +50,13 @@ struct i_poll_events; // This class implements socket polling mechanism using the AIX-specific // pollset mechanism. -class pollset_t : public poller_base_t +class pollset_t ZMQ_FINAL : public poller_base_t { public: typedef void *handle_t; pollset_t (const thread_ctx_t &ctx_); - ~pollset_t (); + ~pollset_t () ZMQ_FINAL; // "poller" concept. handle_t add_fd (fd_t fd_, zmq::i_poll_events *events_); @@ -75,7 +75,7 @@ class pollset_t : public poller_base_t static void worker_routine (void *arg_); // Main event loop. - void loop (); + void loop () ZMQ_FINAL; // Reference to ZMQ context. const thread_ctx_t &ctx; diff --git a/src/pub.hpp b/src/pub.hpp index 86a0c2ee..779cbcc2 100644 --- a/src/pub.hpp +++ b/src/pub.hpp @@ -39,18 +39,18 @@ class io_thread_t; class socket_base_t; class msg_t; -class pub_t : public xpub_t +class pub_t ZMQ_FINAL : public xpub_t { public: pub_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_); - ~pub_t (); + ~pub_t () ZMQ_FINAL; // Implementations of virtual functions from socket_base_t. void xattach_pipe (zmq::pipe_t *pipe_, bool subscribe_to_all_ = false, - bool locally_initiated_ = false); - int xrecv (zmq::msg_t *msg_); - bool xhas_in (); + bool locally_initiated_ = false) ZMQ_FINAL; + int xrecv (zmq::msg_t *msg_) ZMQ_FINAL; + bool xhas_in () ZMQ_FINAL; ZMQ_NON_COPYABLE_NOR_MOVABLE (pub_t) }; diff --git a/src/pull.hpp b/src/pull.hpp index f90f4827..fc9fb22f 100644 --- a/src/pull.hpp +++ b/src/pull.hpp @@ -41,21 +41,21 @@ class pipe_t; class msg_t; class io_thread_t; -class pull_t : public socket_base_t +class pull_t ZMQ_FINAL : public socket_base_t { public: pull_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_); - ~pull_t (); + ~pull_t () ZMQ_FINAL; protected: // Overrides of functions from socket_base_t. void xattach_pipe (zmq::pipe_t *pipe_, bool subscribe_to_all_, - bool locally_initiated_); - int xrecv (zmq::msg_t *msg_); - bool xhas_in (); - void xread_activated (zmq::pipe_t *pipe_); - void xpipe_terminated (zmq::pipe_t *pipe_); + bool locally_initiated_) ZMQ_FINAL; + int xrecv (zmq::msg_t *msg_) ZMQ_FINAL; + bool xhas_in () ZMQ_FINAL; + void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL; + void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL; private: // Fair queueing object for inbound pipes. diff --git a/src/push.hpp b/src/push.hpp index cc3e8c37..6fe05ea6 100644 --- a/src/push.hpp +++ b/src/push.hpp @@ -41,21 +41,21 @@ class pipe_t; class msg_t; class io_thread_t; -class push_t : public socket_base_t +class push_t ZMQ_FINAL : public socket_base_t { public: push_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_); - ~push_t (); + ~push_t () ZMQ_FINAL; protected: // Overrides of functions from socket_base_t. void xattach_pipe (zmq::pipe_t *pipe_, bool subscribe_to_all_, - bool locally_initiated_); - int xsend (zmq::msg_t *msg_); - bool xhas_out (); - void xwrite_activated (zmq::pipe_t *pipe_); - void xpipe_terminated (zmq::pipe_t *pipe_); + bool locally_initiated_) ZMQ_FINAL; + int xsend (zmq::msg_t *msg_) ZMQ_FINAL; + bool xhas_out () ZMQ_FINAL; + void xwrite_activated (zmq::pipe_t *pipe_) ZMQ_FINAL; + void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL; private: // Load balancer managing the outbound pipes. diff --git a/src/radio.hpp b/src/radio.hpp index 6becfe09..29d73c55 100644 --- a/src/radio.hpp +++ b/src/radio.hpp @@ -45,24 +45,25 @@ class ctx_t; class pipe_t; class io_thread_t; -class radio_t : public socket_base_t +class radio_t ZMQ_FINAL : public socket_base_t { public: radio_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_); - ~radio_t (); + ~radio_t () ZMQ_FINAL; // Implementations of virtual functions from socket_base_t. void xattach_pipe (zmq::pipe_t *pipe_, bool subscribe_to_all_ = false, - bool locally_initiated_ = false); - int xsend (zmq::msg_t *msg_); - bool xhas_out (); - int xrecv (zmq::msg_t *msg_); - bool xhas_in (); - void xread_activated (zmq::pipe_t *pipe_); - void xwrite_activated (zmq::pipe_t *pipe_); - int xsetsockopt (int option_, const void *optval_, size_t optvallen_); - void xpipe_terminated (zmq::pipe_t *pipe_); + bool locally_initiated_ = false) ZMQ_FINAL; + int xsend (zmq::msg_t *msg_) ZMQ_FINAL; + bool xhas_out () ZMQ_FINAL; + int xrecv (zmq::msg_t *msg_) ZMQ_FINAL; + bool xhas_in () ZMQ_FINAL; + void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL; + void xwrite_activated (zmq::pipe_t *pipe_) ZMQ_FINAL; + int + xsetsockopt (int option_, const void *optval_, size_t optvallen_) ZMQ_FINAL; + void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL; private: // List of all subscriptions mapped to corresponding pipes. @@ -82,7 +83,7 @@ class radio_t : public socket_base_t ZMQ_NON_COPYABLE_NOR_MOVABLE (radio_t) }; -class radio_session_t : public session_base_t +class radio_session_t ZMQ_FINAL : public session_base_t { public: radio_session_t (zmq::io_thread_t *io_thread_, @@ -90,12 +91,12 @@ class radio_session_t : public session_base_t zmq::socket_base_t *socket_, const options_t &options_, address_t *addr_); - ~radio_session_t (); + ~radio_session_t () ZMQ_FINAL; // Overrides of the functions from session_base_t. - int push_msg (msg_t *msg_); - int pull_msg (msg_t *msg_); - void reset (); + int push_msg (msg_t *msg_) ZMQ_FINAL; + int pull_msg (msg_t *msg_) ZMQ_FINAL; + void reset () ZMQ_FINAL; private: enum diff --git a/src/raw_decoder.hpp b/src/raw_decoder.hpp index 32b5d091..bc09b05f 100644 --- a/src/raw_decoder.hpp +++ b/src/raw_decoder.hpp @@ -39,22 +39,23 @@ namespace zmq { // Decoder for 0MQ v1 framing protocol. Converts data stream into messages. -class raw_decoder_t : public i_decoder +class raw_decoder_t ZMQ_FINAL : public i_decoder { public: raw_decoder_t (size_t bufsize_); - virtual ~raw_decoder_t (); + ~raw_decoder_t () ZMQ_FINAL; // i_decoder interface. - virtual void get_buffer (unsigned char **data_, size_t *size_); + void get_buffer (unsigned char **data_, size_t *size_) ZMQ_FINAL; - virtual int - decode (const unsigned char *data_, size_t size_, size_t &bytes_used_); + int decode (const unsigned char *data_, + size_t size_, + size_t &bytes_used_) ZMQ_FINAL; - virtual msg_t *msg () { return &_in_progress; } + msg_t *msg () ZMQ_FINAL { return &_in_progress; } - virtual void resize_buffer (size_t) {} + void resize_buffer (size_t) ZMQ_FINAL {} private: msg_t _in_progress; diff --git a/src/raw_encoder.hpp b/src/raw_encoder.hpp index fcd0a3f4..acbe609c 100644 --- a/src/raw_encoder.hpp +++ b/src/raw_encoder.hpp @@ -40,11 +40,11 @@ namespace zmq { // Encoder for 0MQ framing protocol. Converts messages into data batches. -class raw_encoder_t : public encoder_base_t +class raw_encoder_t ZMQ_FINAL : public encoder_base_t { public: raw_encoder_t (size_t bufsize_); - ~raw_encoder_t (); + ~raw_encoder_t () ZMQ_FINAL; private: void raw_message_ready (); diff --git a/src/raw_engine.hpp b/src/raw_engine.hpp index 0064aee9..6ea01b06 100644 --- a/src/raw_engine.hpp +++ b/src/raw_engine.hpp @@ -54,18 +54,18 @@ class mechanism_t; // This engine handles any socket with SOCK_STREAM semantics, // e.g. TCP socket or an UNIX domain socket. -class raw_engine_t : public stream_engine_base_t +class raw_engine_t ZMQ_FINAL : public stream_engine_base_t { public: raw_engine_t (fd_t fd_, const options_t &options_, const endpoint_uri_pair_t &endpoint_uri_pair_); - ~raw_engine_t (); + ~raw_engine_t () ZMQ_FINAL; protected: - void error (error_reason_t reason_); - void plug_internal (); - bool handshake (); + void error (error_reason_t reason_) ZMQ_FINAL; + void plug_internal () ZMQ_FINAL; + bool handshake () ZMQ_FINAL; private: int push_raw_msg_to_session (msg_t *msg_); diff --git a/src/reaper.hpp b/src/reaper.hpp index d2227c7a..a3fe0170 100644 --- a/src/reaper.hpp +++ b/src/reaper.hpp @@ -40,11 +40,11 @@ namespace zmq class ctx_t; class socket_base_t; -class reaper_t : public object_t, public i_poll_events +class reaper_t ZMQ_FINAL : public object_t, public i_poll_events { public: reaper_t (zmq::ctx_t *ctx_, uint32_t tid_); - ~reaper_t (); + ~reaper_t () ZMQ_FINAL; mailbox_t *get_mailbox (); @@ -52,15 +52,15 @@ class reaper_t : public object_t, public i_poll_events void stop (); // i_poll_events implementation. - void in_event (); - void out_event (); - void timer_event (int id_); + void in_event () ZMQ_FINAL; + void out_event () ZMQ_FINAL; + void timer_event (int id_) ZMQ_FINAL; private: // Command handlers. - void process_stop (); - void process_reap (zmq::socket_base_t *socket_); - void process_reaped (); + void process_stop () ZMQ_FINAL; + void process_reap (zmq::socket_base_t *socket_) ZMQ_FINAL; + void process_reaped () ZMQ_FINAL; // Reaper thread accesses incoming commands via this mailbox. mailbox_t _mailbox; diff --git a/src/rep.hpp b/src/rep.hpp index e3cdd2e7..4537ec26 100644 --- a/src/rep.hpp +++ b/src/rep.hpp @@ -39,17 +39,17 @@ class msg_t; class io_thread_t; class socket_base_t; -class rep_t : public router_t +class rep_t ZMQ_FINAL : public router_t { public: rep_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_); - ~rep_t (); + ~rep_t () ZMQ_FINAL; // Overrides of functions from socket_base_t. - int xsend (zmq::msg_t *msg_); - int xrecv (zmq::msg_t *msg_); - bool xhas_in (); - bool xhas_out (); + int xsend (zmq::msg_t *msg_) ZMQ_FINAL; + int xrecv (zmq::msg_t *msg_) ZMQ_FINAL; + bool xhas_in () ZMQ_FINAL; + bool xhas_out () ZMQ_FINAL; private: // If true, we are in process of sending the reply. If false we are diff --git a/src/req.hpp b/src/req.hpp index 4d27ee21..f5a49e39 100644 --- a/src/req.hpp +++ b/src/req.hpp @@ -40,19 +40,20 @@ class msg_t; class io_thread_t; class socket_base_t; -class req_t : public dealer_t +class req_t ZMQ_FINAL : public dealer_t { public: req_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_); - ~req_t (); + ~req_t () ZMQ_FINAL; // Overrides of functions from socket_base_t. - int xsend (zmq::msg_t *msg_); - int xrecv (zmq::msg_t *msg_); - bool xhas_in (); - bool xhas_out (); - int xsetsockopt (int option_, const void *optval_, size_t optvallen_); - void xpipe_terminated (zmq::pipe_t *pipe_); + int xsend (zmq::msg_t *msg_) ZMQ_FINAL; + int xrecv (zmq::msg_t *msg_) ZMQ_FINAL; + bool xhas_in () ZMQ_FINAL; + bool xhas_out () ZMQ_FINAL; + int + xsetsockopt (int option_, const void *optval_, size_t optvallen_) ZMQ_FINAL; + void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL; protected: // Receive only from the pipe the request was sent to, discarding @@ -86,7 +87,7 @@ class req_t : public dealer_t ZMQ_NON_COPYABLE_NOR_MOVABLE (req_t) }; -class req_session_t : public session_base_t +class req_session_t ZMQ_FINAL : public session_base_t { public: req_session_t (zmq::io_thread_t *io_thread_, @@ -94,11 +95,11 @@ class req_session_t : public session_base_t zmq::socket_base_t *socket_, const options_t &options_, address_t *addr_); - ~req_session_t (); + ~req_session_t () ZMQ_FINAL; // Overrides of the functions from session_base_t. - int push_msg (msg_t *msg_); - void reset (); + int push_msg (msg_t *msg_) ZMQ_FINAL; + void reset () ZMQ_FINAL; private: enum diff --git a/src/router.hpp b/src/router.hpp index a2d70830..f020672f 100644 --- a/src/router.hpp +++ b/src/router.hpp @@ -49,20 +49,22 @@ class router_t : public routing_socket_base_t { public: router_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_); - ~router_t (); + ~router_t () ZMQ_OVERRIDE; // Overrides of functions from socket_base_t. void xattach_pipe (zmq::pipe_t *pipe_, bool subscribe_to_all_, - bool locally_initiated_); - int xsetsockopt (int option_, const void *optval_, size_t optvallen_); - int xsend (zmq::msg_t *msg_); - int xrecv (zmq::msg_t *msg_); - bool xhas_in (); - bool xhas_out (); - void xread_activated (zmq::pipe_t *pipe_); - void xpipe_terminated (zmq::pipe_t *pipe_); - int get_peer_state (const void *routing_id_, size_t routing_id_size_) const; + bool locally_initiated_) ZMQ_FINAL; + int + xsetsockopt (int option_, const void *optval_, size_t optvallen_) ZMQ_FINAL; + int xsend (zmq::msg_t *msg_) ZMQ_OVERRIDE; + int xrecv (zmq::msg_t *msg_) ZMQ_OVERRIDE; + bool xhas_in () ZMQ_OVERRIDE; + bool xhas_out () ZMQ_OVERRIDE; + void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL; + void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL; + int get_peer_state (const void *routing_id_, + size_t routing_id_size_) const ZMQ_FINAL; protected: // Rollback any message parts that were sent but not yet flushed. diff --git a/src/scatter.hpp b/src/scatter.hpp index 0c61adef..a3db5ee9 100644 --- a/src/scatter.hpp +++ b/src/scatter.hpp @@ -41,21 +41,21 @@ class pipe_t; class msg_t; class io_thread_t; -class scatter_t : public socket_base_t +class scatter_t ZMQ_FINAL : public socket_base_t { public: scatter_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_); - ~scatter_t (); + ~scatter_t () ZMQ_FINAL; protected: // Overrides of functions from socket_base_t. void xattach_pipe (zmq::pipe_t *pipe_, bool subscribe_to_all_, - bool locally_initiated_); - int xsend (zmq::msg_t *msg_); - bool xhas_out (); - void xwrite_activated (zmq::pipe_t *pipe_); - void xpipe_terminated (zmq::pipe_t *pipe_); + bool locally_initiated_) ZMQ_FINAL; + int xsend (zmq::msg_t *msg_) ZMQ_FINAL; + bool xhas_out () ZMQ_FINAL; + void xwrite_activated (zmq::pipe_t *pipe_) ZMQ_FINAL; + void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL; private: // Load balancer managing the outbound pipes. diff --git a/src/select.hpp b/src/select.hpp index 708dcf8b..8f18a383 100644 --- a/src/select.hpp +++ b/src/select.hpp @@ -57,13 +57,13 @@ struct i_poll_events; // Implements socket polling mechanism using POSIX.1-2001 select() // function. -class select_t : public worker_poller_base_t +class select_t ZMQ_FINAL : public worker_poller_base_t { public: typedef fd_t handle_t; select_t (const thread_ctx_t &ctx_); - ~select_t (); + ~select_t () ZMQ_FINAL; // "poller" concept. handle_t add_fd (fd_t fd_, zmq::i_poll_events *events_); @@ -78,7 +78,7 @@ class select_t : public worker_poller_base_t private: // Main event loop. - void loop (); + void loop () ZMQ_FINAL; // Internal state. struct fds_set_t diff --git a/src/server.hpp b/src/server.hpp index cef1e4d2..b990d1d9 100644 --- a/src/server.hpp +++ b/src/server.hpp @@ -45,23 +45,23 @@ class msg_t; class pipe_t; // TODO: This class uses O(n) scheduling. Rewrite it to use O(1) algorithm. -class server_t : public socket_base_t +class server_t ZMQ_FINAL : public socket_base_t { public: server_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_); - ~server_t (); + ~server_t () ZMQ_FINAL; // Overrides of functions from socket_base_t. void xattach_pipe (zmq::pipe_t *pipe_, bool subscribe_to_all_, - bool locally_initiated_); - int xsend (zmq::msg_t *msg_); - int xrecv (zmq::msg_t *msg_); - bool xhas_in (); - bool xhas_out (); - void xread_activated (zmq::pipe_t *pipe_); - void xwrite_activated (zmq::pipe_t *pipe_); - void xpipe_terminated (zmq::pipe_t *pipe_); + bool locally_initiated_) ZMQ_FINAL; + int xsend (zmq::msg_t *msg_) ZMQ_FINAL; + int xrecv (zmq::msg_t *msg_) ZMQ_FINAL; + bool xhas_in () ZMQ_FINAL; + bool xhas_out () ZMQ_FINAL; + void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL; + void xwrite_activated (zmq::pipe_t *pipe_) ZMQ_FINAL; + void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL; private: // Fair queueing object for inbound pipes. diff --git a/src/session_base.hpp b/src/session_base.hpp index 42b84e6d..dfe909b8 100644 --- a/src/session_base.hpp +++ b/src/session_base.hpp @@ -65,10 +65,10 @@ class session_base_t : public own_t, public io_object_t, public i_pipe_events void engine_error (zmq::i_engine::error_reason_t reason_); // i_pipe_events interface implementation. - void read_activated (zmq::pipe_t *pipe_); - void write_activated (zmq::pipe_t *pipe_); - void hiccuped (zmq::pipe_t *pipe_); - void pipe_terminated (zmq::pipe_t *pipe_); + void read_activated (zmq::pipe_t *pipe_) ZMQ_FINAL; + void write_activated (zmq::pipe_t *pipe_) ZMQ_FINAL; + void hiccuped (zmq::pipe_t *pipe_) ZMQ_FINAL; + void pipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL; // Delivers a message. Returns 0 if successful; -1 otherwise. // The function takes ownership of the message. @@ -101,7 +101,7 @@ class session_base_t : public own_t, public io_object_t, public i_pipe_events zmq::socket_base_t *socket_, const options_t &options_, address_t *addr_); - virtual ~session_base_t (); + ~session_base_t () ZMQ_OVERRIDE; private: void start_connecting (bool wait_); @@ -138,12 +138,12 @@ class session_base_t : public own_t, public io_object_t, public i_pipe_events void reconnect (); // Handlers for incoming commands. - void process_plug (); - void process_attach (zmq::i_engine *engine_); - void process_term (int linger_); + void process_plug () ZMQ_FINAL; + void process_attach (zmq::i_engine *engine_) ZMQ_FINAL; + void process_term (int linger_) ZMQ_FINAL; // i_poll_events handlers. - void timer_event (int id_); + void timer_event (int id_) ZMQ_FINAL; // Remove any half processed messages. Flush unflushed messages. // Call this function when engine disconnect to get rid of leftovers. diff --git a/src/socket_base.hpp b/src/socket_base.hpp index 5fd0f485..82742a86 100644 --- a/src/socket_base.hpp +++ b/src/socket_base.hpp @@ -107,15 +107,15 @@ class socket_base_t : public own_t, // i_poll_events implementation. This interface is used when socket // is handled by the poller in the reaper thread. - void in_event (); - void out_event (); - void timer_event (int id_); + void in_event () ZMQ_FINAL; + void out_event () ZMQ_FINAL; + void timer_event (int id_) ZMQ_FINAL; // i_pipe_events interface implementation. - void read_activated (pipe_t *pipe_); - void write_activated (pipe_t *pipe_); - void hiccuped (pipe_t *pipe_); - void pipe_terminated (pipe_t *pipe_); + void read_activated (pipe_t *pipe_) ZMQ_FINAL; + void write_activated (pipe_t *pipe_) ZMQ_FINAL; + void hiccuped (pipe_t *pipe_) ZMQ_FINAL; + void pipe_terminated (pipe_t *pipe_) ZMQ_FINAL; void lock (); void unlock (); @@ -170,7 +170,7 @@ class socket_base_t : public own_t, uint32_t tid_, int sid_, bool thread_safe_ = false); - virtual ~socket_base_t (); + ~socket_base_t () ZMQ_OVERRIDE; // Concrete algorithms for the x- methods are to be defined by // individual socket types. @@ -179,7 +179,7 @@ class socket_base_t : public own_t, bool locally_initiated_ = false) = 0; // The default implementation assumes there are no specific socket - // options for the particular socket type. If not so, override this + // options for the particular socket type. If not so, ZMQ_FINAL this // method. virtual int xsetsockopt (int option_, const void *optval_, size_t optvallen_); @@ -203,7 +203,7 @@ class socket_base_t : public own_t, virtual int xleave (const char *group_); // Delay actual destruction of the socket. - void process_destroy (); + void process_destroy () ZMQ_FINAL; private: // test if event should be sent and then dispatch it @@ -284,13 +284,14 @@ class socket_base_t : public own_t, int process_commands (int timeout_, bool throttle_); // Handlers for incoming commands. - void process_stop (); - void process_bind (zmq::pipe_t *pipe_); - void process_pipe_stats_publish (uint64_t outbound_queue_count_, - uint64_t inbound_queue_count_, - endpoint_uri_pair_t *endpoint_pair_); - void process_term (int linger_); - void process_term_endpoint (std::string *endpoint_); + void process_stop () ZMQ_FINAL; + void process_bind (zmq::pipe_t *pipe_) ZMQ_FINAL; + void + process_pipe_stats_publish (uint64_t outbound_queue_count_, + uint64_t inbound_queue_count_, + endpoint_uri_pair_t *endpoint_pair_) ZMQ_FINAL; + void process_term (int linger_) ZMQ_FINAL; + void process_term_endpoint (std::string *endpoint_) ZMQ_FINAL; void update_pipe_options (int option_); @@ -348,12 +349,13 @@ class routing_socket_base_t : public socket_base_t { protected: routing_socket_base_t (class ctx_t *parent_, uint32_t tid_, int sid_); - ~routing_socket_base_t (); + ~routing_socket_base_t () ZMQ_OVERRIDE; // methods from socket_base_t - virtual int - xsetsockopt (int option_, const void *optval_, size_t optvallen_); - virtual void xwrite_activated (pipe_t *pipe_); + int xsetsockopt (int option_, + const void *optval_, + size_t optvallen_) ZMQ_OVERRIDE; + void xwrite_activated (pipe_t *pipe_) ZMQ_FINAL; // own methods std::string extract_connect_routing_id (); diff --git a/src/socks_connecter.hpp b/src/socks_connecter.hpp index 549f29f5..3e17a2e1 100644 --- a/src/socks_connecter.hpp +++ b/src/socks_connecter.hpp @@ -41,7 +41,7 @@ class io_thread_t; class session_base_t; struct address_t; -class socks_connecter_t : public stream_connecter_base_t +class socks_connecter_t ZMQ_FINAL : public stream_connecter_base_t { public: // If 'delayed_start' is true connecter first waits for a while, @@ -52,7 +52,7 @@ class socks_connecter_t : public stream_connecter_base_t address_t *addr_, address_t *proxy_addr_, bool delayed_start_); - ~socks_connecter_t (); + ~socks_connecter_t () ZMQ_FINAL; void set_auth_method_basic (const std::string &username, const std::string &password); @@ -82,11 +82,11 @@ class socks_connecter_t : public stream_connecter_base_t }; // Handlers for I/O events. - virtual void in_event (); - virtual void out_event (); + void in_event () ZMQ_FINAL; + void out_event () ZMQ_FINAL; // Internal function to start the actual connection establishment. - void start_connecting (); + void start_connecting () ZMQ_FINAL; int process_server_response (const socks_choice_t &response_); int process_server_response (const socks_response_t &response_); diff --git a/src/stream.hpp b/src/stream.hpp index 3ac95a84..89fdf1af 100644 --- a/src/stream.hpp +++ b/src/stream.hpp @@ -39,23 +39,24 @@ namespace zmq class ctx_t; class pipe_t; -class stream_t : public routing_socket_base_t +class stream_t ZMQ_FINAL : public routing_socket_base_t { public: stream_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_); - ~stream_t (); + ~stream_t () ZMQ_FINAL; // Overrides of functions from socket_base_t. void xattach_pipe (zmq::pipe_t *pipe_, bool subscribe_to_all_, - bool locally_initiated_); - int xsend (zmq::msg_t *msg_); - int xrecv (zmq::msg_t *msg_); - bool xhas_in (); - bool xhas_out (); - void xread_activated (zmq::pipe_t *pipe_); - void xpipe_terminated (zmq::pipe_t *pipe_); - int xsetsockopt (int option_, const void *optval_, size_t optvallen_); + bool locally_initiated_) ZMQ_FINAL; + int xsend (zmq::msg_t *msg_) ZMQ_FINAL; + int xrecv (zmq::msg_t *msg_) ZMQ_FINAL; + bool xhas_in () ZMQ_FINAL; + bool xhas_out () ZMQ_FINAL; + void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL; + void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL; + int + xsetsockopt (int option_, const void *optval_, size_t optvallen_) ZMQ_FINAL; private: // Generate peer's id and update lookup map diff --git a/src/stream_connecter_base.hpp b/src/stream_connecter_base.hpp index 2d580451..c2accbe3 100644 --- a/src/stream_connecter_base.hpp +++ b/src/stream_connecter_base.hpp @@ -51,16 +51,16 @@ class stream_connecter_base_t : public own_t, public io_object_t address_t *addr_, bool delayed_start_); - ~stream_connecter_base_t (); + ~stream_connecter_base_t () ZMQ_OVERRIDE; protected: // Handlers for incoming commands. - void process_plug (); - void process_term (int linger_); + void process_plug () ZMQ_FINAL; + void process_term (int linger_) ZMQ_OVERRIDE; // Handlers for I/O events. - void in_event (); - void timer_event (int id_); + void in_event () ZMQ_OVERRIDE; + void timer_event (int id_) ZMQ_OVERRIDE; // Internal function to create the engine after connection was established. virtual void create_engine (fd_t fd, const std::string &local_address_); diff --git a/src/stream_engine_base.hpp b/src/stream_engine_base.hpp index a063ece1..16ecc96f 100644 --- a/src/stream_engine_base.hpp +++ b/src/stream_engine_base.hpp @@ -58,20 +58,21 @@ class stream_engine_base_t : public io_object_t, public i_engine stream_engine_base_t (fd_t fd_, const options_t &options_, const endpoint_uri_pair_t &endpoint_uri_pair_); - ~stream_engine_base_t (); + ~stream_engine_base_t () ZMQ_OVERRIDE; // i_engine interface implementation. - void plug (zmq::io_thread_t *io_thread_, zmq::session_base_t *session_); - void terminate (); - bool restart_input (); - void restart_output (); - void zap_msg_available (); - const endpoint_uri_pair_t &get_endpoint () const; + void plug (zmq::io_thread_t *io_thread_, + zmq::session_base_t *session_) ZMQ_FINAL; + void terminate () ZMQ_FINAL; + bool restart_input () ZMQ_FINAL; + void restart_output () ZMQ_FINAL; + void zap_msg_available () ZMQ_FINAL; + const endpoint_uri_pair_t &get_endpoint () const ZMQ_FINAL; // i_poll_events interface implementation. - void in_event (); - void out_event (); - void timer_event (int id_); + void in_event () ZMQ_FINAL; + void out_event () ZMQ_FINAL; + void timer_event (int id_) ZMQ_FINAL; protected: typedef metadata_t::dict_t properties_t; diff --git a/src/stream_listener_base.hpp b/src/stream_listener_base.hpp index 4d85d555..71582541 100644 --- a/src/stream_listener_base.hpp +++ b/src/stream_listener_base.hpp @@ -49,7 +49,7 @@ class stream_listener_base_t : public own_t, public io_object_t stream_listener_base_t (zmq::io_thread_t *io_thread_, zmq::socket_base_t *socket_, const options_t &options_); - ~stream_listener_base_t (); + ~stream_listener_base_t () ZMQ_OVERRIDE; // Get the bound address for use with wildcards int get_local_address (std::string &addr_) const; @@ -60,8 +60,8 @@ class stream_listener_base_t : public own_t, public io_object_t private: // Handlers for incoming commands. - void process_plug (); - void process_term (int linger_); + void process_plug () ZMQ_FINAL; + void process_term (int linger_) ZMQ_FINAL; protected: // Close the listening socket. diff --git a/src/sub.hpp b/src/sub.hpp index 9b493dfc..046e838c 100644 --- a/src/sub.hpp +++ b/src/sub.hpp @@ -39,16 +39,17 @@ class msg_t; class io_thread_t; class socket_base_t; -class sub_t : public xsub_t +class sub_t ZMQ_FINAL : public xsub_t { public: sub_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_); - ~sub_t (); + ~sub_t () ZMQ_FINAL; protected: - int xsetsockopt (int option_, const void *optval_, size_t optvallen_); - int xsend (zmq::msg_t *msg_); - bool xhas_out (); + int + xsetsockopt (int option_, const void *optval_, size_t optvallen_) ZMQ_FINAL; + int xsend (zmq::msg_t *msg_) ZMQ_FINAL; + bool xhas_out () ZMQ_FINAL; ZMQ_NON_COPYABLE_NOR_MOVABLE (sub_t) }; diff --git a/src/tcp_connecter.hpp b/src/tcp_connecter.hpp index 4ad581b3..1202718e 100644 --- a/src/tcp_connecter.hpp +++ b/src/tcp_connecter.hpp @@ -36,7 +36,7 @@ namespace zmq { -class tcp_connecter_t : public stream_connecter_base_t +class tcp_connecter_t ZMQ_FINAL : public stream_connecter_base_t { public: // If 'delayed_start' is true connecter first waits for a while, @@ -46,7 +46,7 @@ class tcp_connecter_t : public stream_connecter_base_t const options_t &options_, address_t *addr_, bool delayed_start_); - ~tcp_connecter_t (); + ~tcp_connecter_t () ZMQ_FINAL; private: // ID of the timer used to check the connect timeout, must be different from stream_connecter_base_t::reconnect_timer_id. @@ -56,14 +56,14 @@ class tcp_connecter_t : public stream_connecter_base_t }; // Handlers for incoming commands. - void process_term (int linger_); + void process_term (int linger_) ZMQ_FINAL; // Handlers for I/O events. - void out_event (); - void timer_event (int id_); + void out_event () ZMQ_FINAL; + void timer_event (int id_) ZMQ_FINAL; // Internal function to start the actual connection establishment. - void start_connecting (); + void start_connecting () ZMQ_FINAL; // Internal function to add a connect timer void add_connect_timer (); diff --git a/src/tcp_listener.hpp b/src/tcp_listener.hpp index 60aac5a0..b0080572 100644 --- a/src/tcp_listener.hpp +++ b/src/tcp_listener.hpp @@ -36,7 +36,7 @@ namespace zmq { -class tcp_listener_t : public stream_listener_base_t +class tcp_listener_t ZMQ_FINAL : public stream_listener_base_t { public: tcp_listener_t (zmq::io_thread_t *io_thread_, @@ -47,11 +47,12 @@ class tcp_listener_t : public stream_listener_base_t int set_local_address (const char *addr_); protected: - std::string get_socket_name (fd_t fd_, socket_end_t socket_end_) const; + std::string get_socket_name (fd_t fd_, + socket_end_t socket_end_) const ZMQ_FINAL; private: // Handlers for I/O events. - void in_event (); + void in_event () ZMQ_FINAL; // Accept the new connection. Returns the file descriptor of the // newly created connection. The function may return retired_fd diff --git a/src/tipc_connecter.hpp b/src/tipc_connecter.hpp index 56fb337f..e12643ff 100644 --- a/src/tipc_connecter.hpp +++ b/src/tipc_connecter.hpp @@ -39,7 +39,7 @@ namespace zmq { -class tipc_connecter_t : public stream_connecter_base_t +class tipc_connecter_t ZMQ_FINAL : public stream_connecter_base_t { public: // If 'delayed_start' is true connecter first waits for a while, @@ -52,10 +52,10 @@ class tipc_connecter_t : public stream_connecter_base_t private: // Handlers for I/O events. - void out_event (); + void out_event () ZMQ_FINAL; // Internal function to start the actual connection establishment. - void start_connecting (); + void start_connecting () ZMQ_FINAL; // Get the file descriptor of newly created connection. Returns // retired_fd if the connection was unsuccessful. diff --git a/src/tipc_listener.hpp b/src/tipc_listener.hpp index 9ffbb943..040a99e6 100644 --- a/src/tipc_listener.hpp +++ b/src/tipc_listener.hpp @@ -42,7 +42,7 @@ namespace zmq { -class tipc_listener_t : public stream_listener_base_t +class tipc_listener_t ZMQ_FINAL : public stream_listener_base_t { public: tipc_listener_t (zmq::io_thread_t *io_thread_, @@ -53,11 +53,12 @@ class tipc_listener_t : public stream_listener_base_t int set_local_address (const char *addr_); protected: - std::string get_socket_name (fd_t fd_, socket_end_t socket_end_) const; + std::string get_socket_name (fd_t fd_, + socket_end_t socket_end_) const ZMQ_FINAL; private: // Handlers for I/O events. - void in_event (); + void in_event () ZMQ_FINAL; // Accept the new connection. Returns the file descriptor of the // newly created connection. The function may return retired_fd diff --git a/src/udp_engine.hpp b/src/udp_engine.hpp index db4c30c5..084e4dfe 100644 --- a/src/udp_engine.hpp +++ b/src/udp_engine.hpp @@ -14,36 +14,37 @@ namespace zmq class io_thread_t; class session_base_t; -class udp_engine_t : public io_object_t, public i_engine +class udp_engine_t ZMQ_FINAL : public io_object_t, public i_engine { public: udp_engine_t (const options_t &options_); - ~udp_engine_t (); + ~udp_engine_t () ZMQ_FINAL; int init (address_t *address_, bool send_, bool recv_); // i_engine interface implementation. // Plug the engine to the session. - void plug (zmq::io_thread_t *io_thread_, class session_base_t *session_); + void plug (zmq::io_thread_t *io_thread_, + class session_base_t *session_) ZMQ_FINAL; // Terminate and deallocate the engine. Note that 'detached' // events are not fired on termination. - void terminate (); + void terminate () ZMQ_FINAL; // This method is called by the session to signalise that more // messages can be written to the pipe. - bool restart_input (); + bool restart_input () ZMQ_FINAL; // This method is called by the session to signalise that there // are messages to send available. - void restart_output (); + void restart_output () ZMQ_FINAL; - void zap_msg_available (){}; + void zap_msg_available () ZMQ_FINAL{}; - void in_event (); - void out_event (); + void in_event () ZMQ_FINAL; + void out_event () ZMQ_FINAL; - const endpoint_uri_pair_t &get_endpoint () const; + const endpoint_uri_pair_t &get_endpoint () const ZMQ_FINAL; private: int resolve_raw_address (char *name_, size_t length_); diff --git a/src/v1_decoder.hpp b/src/v1_decoder.hpp index 6c153bbe..6b219a64 100644 --- a/src/v1_decoder.hpp +++ b/src/v1_decoder.hpp @@ -36,13 +36,13 @@ namespace zmq { // Decoder for ZMTP/1.0 protocol. Converts data batches into messages. -class v1_decoder_t : public decoder_base_t +class v1_decoder_t ZMQ_FINAL : public decoder_base_t { public: v1_decoder_t (size_t bufsize_, int64_t maxmsgsize_); - ~v1_decoder_t (); + ~v1_decoder_t () ZMQ_FINAL; - virtual msg_t *msg () { return &_in_progress; } + msg_t *msg () ZMQ_FINAL { return &_in_progress; } private: int one_byte_size_ready (unsigned char const *); diff --git a/src/v1_encoder.hpp b/src/v1_encoder.hpp index ef85bb6d..5427b241 100644 --- a/src/v1_encoder.hpp +++ b/src/v1_encoder.hpp @@ -36,11 +36,11 @@ namespace zmq { // Encoder for ZMTP/1.0 protocol. Converts messages into data batches. -class v1_encoder_t : public encoder_base_t +class v1_encoder_t ZMQ_FINAL : public encoder_base_t { public: v1_encoder_t (size_t bufsize_); - ~v1_encoder_t (); + ~v1_encoder_t () ZMQ_FINAL; private: void size_ready (); diff --git a/src/v2_decoder.hpp b/src/v2_decoder.hpp index 04020486..fa91accd 100644 --- a/src/v2_decoder.hpp +++ b/src/v2_decoder.hpp @@ -38,15 +38,15 @@ namespace zmq // Decoder for ZMTP/2.x framing protocol. Converts data stream into messages. // The class has to inherit from shared_message_memory_allocator because // the base class calls allocate in its constructor. -class v2_decoder_t +class v2_decoder_t ZMQ_FINAL : public decoder_base_t { public: v2_decoder_t (size_t bufsize_, int64_t maxmsgsize_, bool zero_copy_); - virtual ~v2_decoder_t (); + ~v2_decoder_t () ZMQ_FINAL; // i_decoder interface. - virtual msg_t *msg () { return &_in_progress; } + msg_t *msg () ZMQ_FINAL { return &_in_progress; } private: int flags_ready (unsigned char const *); diff --git a/src/v2_encoder.hpp b/src/v2_encoder.hpp index 8cb7b394..36cfa9e4 100644 --- a/src/v2_encoder.hpp +++ b/src/v2_encoder.hpp @@ -36,11 +36,11 @@ namespace zmq { // Encoder for 0MQ framing protocol. Converts messages into data stream. -class v2_encoder_t : public encoder_base_t +class v2_encoder_t ZMQ_FINAL : public encoder_base_t { public: v2_encoder_t (size_t bufsize_); - virtual ~v2_encoder_t (); + ~v2_encoder_t () ZMQ_FINAL; private: void size_ready (); diff --git a/src/vmci_connecter.hpp b/src/vmci_connecter.hpp index ca391cd9..d0ebaac9 100644 --- a/src/vmci_connecter.hpp +++ b/src/vmci_connecter.hpp @@ -46,7 +46,7 @@ class session_base_t; struct address_t; // TODO consider refactoring this to derive from stream_connecter_base_t -class vmci_connecter_t : public own_t, public io_object_t +class vmci_connecter_t ZMQ_FINAL : public own_t, public io_object_t { public: // If 'delayed_start' is true connecter first waits for a while, diff --git a/src/vmci_listener.hpp b/src/vmci_listener.hpp index ab2efa7c..4ab11842 100644 --- a/src/vmci_listener.hpp +++ b/src/vmci_listener.hpp @@ -47,7 +47,7 @@ class io_thread_t; class socket_base_t; // TODO consider refactoring this to derive from stream_listener_base_t -class vmci_listener_t : public own_t, public io_object_t +class vmci_listener_t ZMQ_FINAL : public own_t, public io_object_t { public: vmci_listener_t (zmq::io_thread_t *io_thread_, diff --git a/src/ws_connecter.hpp b/src/ws_connecter.hpp index 20b8b1b9..a6410772 100644 --- a/src/ws_connecter.hpp +++ b/src/ws_connecter.hpp @@ -36,7 +36,7 @@ namespace zmq { -class ws_connecter_t : public stream_connecter_base_t +class ws_connecter_t ZMQ_FINAL : public stream_connecter_base_t { public: // If 'delayed_start' is true connecter first waits for a while, @@ -48,10 +48,10 @@ class ws_connecter_t : public stream_connecter_base_t bool delayed_start_, bool wss_, const std::string &tls_hostname_); - ~ws_connecter_t (); + ~ws_connecter_t () ZMQ_FINAL; protected: - void create_engine (fd_t fd, const std::string &local_address_); + void create_engine (fd_t fd, const std::string &local_address_) ZMQ_FINAL; private: // ID of the timer used to check the connect timeout, must be different from stream_connecter_base_t::reconnect_timer_id. @@ -61,14 +61,14 @@ class ws_connecter_t : public stream_connecter_base_t }; // Handlers for incoming commands. - void process_term (int linger_); + void process_term (int linger_) ZMQ_FINAL; // Handlers for I/O events. - void out_event (); - void timer_event (int id_); + void out_event () ZMQ_FINAL; + void timer_event (int id_) ZMQ_FINAL; // Internal function to start the actual connection establishment. - void start_connecting (); + void start_connecting () ZMQ_FINAL; // Internal function to add a connect timer void add_connect_timer (); diff --git a/src/ws_decoder.hpp b/src/ws_decoder.hpp index 8e13ba25..00eb4014 100644 --- a/src/ws_decoder.hpp +++ b/src/ws_decoder.hpp @@ -39,7 +39,7 @@ namespace zmq // Decoder for Web socket framing protocol. Converts data stream into messages. // The class has to inherit from shared_message_memory_allocator because // the base class calls allocate in its constructor. -class ws_decoder_t +class ws_decoder_t ZMQ_FINAL : public decoder_base_t { public: @@ -47,10 +47,10 @@ class ws_decoder_t int64_t maxmsgsize_, bool zero_copy_, bool must_mask_); - virtual ~ws_decoder_t (); + ~ws_decoder_t () ZMQ_FINAL; // i_decoder interface. - virtual msg_t *msg () { return &_in_progress; } + msg_t *msg () ZMQ_FINAL { return &_in_progress; } private: int opcode_ready (unsigned char const *); diff --git a/src/ws_encoder.hpp b/src/ws_encoder.hpp index 98f6d2b2..ad7b1784 100644 --- a/src/ws_encoder.hpp +++ b/src/ws_encoder.hpp @@ -36,11 +36,11 @@ namespace zmq { // Encoder for web socket framing protocol. Converts messages into data stream. -class ws_encoder_t : public encoder_base_t +class ws_encoder_t ZMQ_FINAL : public encoder_base_t { public: ws_encoder_t (size_t bufsize_, bool must_mask_); - virtual ~ws_encoder_t (); + ~ws_encoder_t () ZMQ_FINAL; private: void size_ready (); diff --git a/src/ws_engine.hpp b/src/ws_engine.hpp index 5846c918..f573e675 100644 --- a/src/ws_engine.hpp +++ b/src/ws_engine.hpp @@ -124,7 +124,7 @@ typedef enum client_handshake_error = -1 } ws_client_handshake_state_t; -class ws_engine_t : public stream_engine_base_t +class ws_engine_t ZMQ_FINAL : public stream_engine_base_t { public: ws_engine_t (fd_t fd_, @@ -132,7 +132,7 @@ class ws_engine_t : public stream_engine_base_t const endpoint_uri_pair_t &endpoint_uri_pair_, ws_address_t &address_, bool client_); - ~ws_engine_t (); + ~ws_engine_t () ZMQ_FINAL; protected: int decode_and_push (msg_t *msg_); diff --git a/src/ws_listener.hpp b/src/ws_listener.hpp index bce8e1a2..509ba33e 100644 --- a/src/ws_listener.hpp +++ b/src/ws_listener.hpp @@ -40,7 +40,7 @@ namespace zmq { -class ws_listener_t : public stream_listener_base_t +class ws_listener_t ZMQ_FINAL : public stream_listener_base_t { public: ws_listener_t (zmq::io_thread_t *io_thread_, @@ -48,18 +48,19 @@ class ws_listener_t : public stream_listener_base_t const options_t &options_, bool wss_); - ~ws_listener_t (); + ~ws_listener_t () ZMQ_FINAL; // Set address to listen on. int set_local_address (const char *addr_); protected: - std::string get_socket_name (fd_t fd_, socket_end_t socket_end_) const; - void create_engine (fd_t fd); + std::string get_socket_name (fd_t fd_, + socket_end_t socket_end_) const ZMQ_FINAL; + void create_engine (fd_t fd) ZMQ_FINAL; private: // Handlers for I/O events. - void in_event (); + void in_event () ZMQ_FINAL; // Accept the new connection. Returns the file descriptor of the // newly created connection. The function may return retired_fd diff --git a/src/xpub.hpp b/src/xpub.hpp index 5414dd0d..82504b0e 100644 --- a/src/xpub.hpp +++ b/src/xpub.hpp @@ -48,20 +48,21 @@ class xpub_t : public socket_base_t { public: xpub_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_); - ~xpub_t (); + ~xpub_t () ZMQ_OVERRIDE; // Implementations of virtual functions from socket_base_t. void xattach_pipe (zmq::pipe_t *pipe_, bool subscribe_to_all_ = false, - bool locally_initiated_ = false); - int xsend (zmq::msg_t *msg_); - bool xhas_out (); - int xrecv (zmq::msg_t *msg_); - bool xhas_in (); - void xread_activated (zmq::pipe_t *pipe_); - void xwrite_activated (zmq::pipe_t *pipe_); - int xsetsockopt (int option_, const void *optval_, size_t optvallen_); - void xpipe_terminated (zmq::pipe_t *pipe_); + bool locally_initiated_ = false) ZMQ_OVERRIDE; + int xsend (zmq::msg_t *msg_) ZMQ_FINAL; + bool xhas_out () ZMQ_FINAL; + int xrecv (zmq::msg_t *msg_) ZMQ_OVERRIDE; + bool xhas_in () ZMQ_OVERRIDE; + void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL; + void xwrite_activated (zmq::pipe_t *pipe_) ZMQ_FINAL; + int + xsetsockopt (int option_, const void *optval_, size_t optvallen_) ZMQ_FINAL; + void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL; private: // Function to be applied to the trie to send all the subscriptions diff --git a/src/xsub.hpp b/src/xsub.hpp index cea6c288..6bbbce07 100644 --- a/src/xsub.hpp +++ b/src/xsub.hpp @@ -50,22 +50,24 @@ class xsub_t : public socket_base_t { public: xsub_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_); - ~xsub_t (); + ~xsub_t () ZMQ_OVERRIDE; protected: // Overrides of functions from socket_base_t. void xattach_pipe (zmq::pipe_t *pipe_, bool subscribe_to_all_, - bool locally_initiated_); - int xsetsockopt (int option_, const void *optval_, size_t optvallen_); - int xsend (zmq::msg_t *msg_); - bool xhas_out (); - int xrecv (zmq::msg_t *msg_); - bool xhas_in (); - void xread_activated (zmq::pipe_t *pipe_); - void xwrite_activated (zmq::pipe_t *pipe_); - void xhiccuped (pipe_t *pipe_); - void xpipe_terminated (zmq::pipe_t *pipe_); + bool locally_initiated_) ZMQ_FINAL; + int xsetsockopt (int option_, + const void *optval_, + size_t optvallen_) ZMQ_OVERRIDE; + int xsend (zmq::msg_t *msg_) ZMQ_OVERRIDE; + bool xhas_out () ZMQ_OVERRIDE; + int xrecv (zmq::msg_t *msg_) ZMQ_FINAL; + bool xhas_in () ZMQ_FINAL; + void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL; + void xwrite_activated (zmq::pipe_t *pipe_) ZMQ_FINAL; + void xhiccuped (pipe_t *pipe_) ZMQ_FINAL; + void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL; private: // Check whether the message matches at least one subscription. diff --git a/src/ypipe.hpp b/src/ypipe.hpp index f8d68ca5..d730b467 100644 --- a/src/ypipe.hpp +++ b/src/ypipe.hpp @@ -43,7 +43,7 @@ namespace zmq // N is granularity of the pipe, i.e. how many items are needed to // perform next memory allocation. -template class ypipe_t : public ypipe_base_t +template class ypipe_t ZMQ_FINAL : public ypipe_base_t { public: // Initialises the pipe. @@ -71,7 +71,7 @@ template class ypipe_t : public ypipe_base_t // set to true the item is assumed to be continued by items // subsequently written to the pipe. Incomplete items are never // flushed down the stream. - inline void write (const T &value_, bool incomplete_) + inline void write (const T &value_, bool incomplete_) ZMQ_FINAL { // Place the value to the queue, add new terminator element. _queue.back () = value_; @@ -88,7 +88,7 @@ template class ypipe_t : public ypipe_base_t // Pop an incomplete item from the pipe. Returns true if such // item exists, false otherwise. - inline bool unwrite (T *value_) + inline bool unwrite (T *value_) ZMQ_FINAL { if (_f == &_queue.back ()) return false; @@ -100,7 +100,7 @@ template class ypipe_t : public ypipe_base_t // Flush all the completed items into the pipe. Returns false if // the reader thread is sleeping. In that case, caller is obliged to // wake the reader up before using the pipe again. - inline bool flush () + inline bool flush () ZMQ_FINAL { // If there are no un-flushed items, do nothing. if (_w == _f) @@ -125,7 +125,7 @@ template class ypipe_t : public ypipe_base_t } // Check whether item is available for reading. - inline bool check_read () + inline bool check_read () ZMQ_FINAL { // Was the value prefetched already? If so, return. if (&_queue.front () != _r && _r) @@ -150,7 +150,7 @@ template class ypipe_t : public ypipe_base_t // Reads an item from the pipe. Returns false if there is no value. // available. - inline bool read (T *value_) + inline bool read (T *value_) ZMQ_FINAL { // Try to prefetch a value. if (!check_read ()) @@ -166,7 +166,7 @@ template class ypipe_t : public ypipe_base_t // Applies the function fn to the first elemenent in the pipe // and returns the value returned by the fn. // The pipe mustn't be empty or the function crashes. - inline bool probe (bool (*fn_) (const T &)) + inline bool probe (bool (*fn_) (const T &)) ZMQ_FINAL { bool rc = check_read (); zmq_assert (rc); diff --git a/src/ypipe_conflate.hpp b/src/ypipe_conflate.hpp index 48ba3cfd..fe010d72 100644 --- a/src/ypipe_conflate.hpp +++ b/src/ypipe_conflate.hpp @@ -43,7 +43,7 @@ namespace zmq // reader_awake flag is needed here to mimic ypipe delicate behaviour // around the reader being asleep (see 'c' pointer being NULL in ypipe.hpp) -template class ypipe_conflate_t : public ypipe_base_t +template class ypipe_conflate_t ZMQ_FINAL : public ypipe_base_t { public: // Initialises the pipe. @@ -57,7 +57,7 @@ template class ypipe_conflate_t : public ypipe_base_t #pragma message save #pragma message disable(UNINIT) #endif - inline void write (const T &value_, bool incomplete_) + inline void write (const T &value_, bool incomplete_) ZMQ_FINAL { (void) incomplete_; @@ -69,16 +69,16 @@ template class ypipe_conflate_t : public ypipe_base_t #endif // There are no incomplete items for conflate ypipe - inline bool unwrite (T *) { return false; } + inline bool unwrite (T *) ZMQ_FINAL { return false; } // Flush is no-op for conflate ypipe. Reader asleep behaviour // is as of the usual ypipe. // Returns false if the reader thread is sleeping. In that case, // caller is obliged to wake the reader up before using the pipe again. - inline bool flush () { return reader_awake; } + inline bool flush () ZMQ_FINAL { return reader_awake; } // Check whether item is available for reading. - inline bool check_read () + inline bool check_read () ZMQ_FINAL { bool res = dbuffer.check_read (); if (!res) @@ -89,7 +89,7 @@ template class ypipe_conflate_t : public ypipe_base_t // Reads an item from the pipe. Returns false if there is no value. // available. - inline bool read (T *value_) + inline bool read (T *value_) ZMQ_FINAL { if (!check_read ()) return false; @@ -100,7 +100,10 @@ template class ypipe_conflate_t : public ypipe_base_t // Applies the function fn to the first elemenent in the pipe // and returns the value returned by the fn. // The pipe mustn't be empty or the function crashes. - inline bool probe (bool (*fn_) (const T &)) { return dbuffer.probe (fn_); } + inline bool probe (bool (*fn_) (const T &)) ZMQ_FINAL + { + return dbuffer.probe (fn_); + } protected: dbuffer_t dbuffer; diff --git a/src/zap_client.hpp b/src/zap_client.hpp index b51ca4be..2f4fc100 100644 --- a/src/zap_client.hpp +++ b/src/zap_client.hpp @@ -83,12 +83,12 @@ class zap_client_common_handshake_t : public zap_client_t state_t zap_reply_ok_state_); // methods from mechanism_t - status_t status () const; - int zap_msg_available (); + status_t status () const ZMQ_FINAL; + int zap_msg_available () ZMQ_FINAL; // zap_client_t methods - int receive_and_process_zap_reply (); - void handle_zap_status_code (); + int receive_and_process_zap_reply () ZMQ_FINAL; + void handle_zap_status_code () ZMQ_FINAL; // Current FSM state state_t state; diff --git a/src/zmtp_engine.hpp b/src/zmtp_engine.hpp index aac21be8..d9f9e75e 100644 --- a/src/zmtp_engine.hpp +++ b/src/zmtp_engine.hpp @@ -59,24 +59,24 @@ class mechanism_t; // This engine handles any socket with SOCK_STREAM semantics, // e.g. TCP socket or an UNIX domain socket. -class zmtp_engine_t : public stream_engine_base_t +class zmtp_engine_t ZMQ_FINAL : public stream_engine_base_t { public: zmtp_engine_t (fd_t fd_, const options_t &options_, const endpoint_uri_pair_t &endpoint_uri_pair_); - ~zmtp_engine_t (); + ~zmtp_engine_t () ZMQ_FINAL; protected: // Detects the protocol used by the peer. - bool handshake (); + bool handshake () ZMQ_FINAL; - void plug_internal (); + void plug_internal () ZMQ_FINAL; - int process_command_message (msg_t *msg_); - int produce_ping_message (msg_t *msg_); - int process_heartbeat_message (msg_t *msg_); - int produce_pong_message (msg_t *msg_); + int process_command_message (msg_t *msg_) ZMQ_FINAL; + int produce_ping_message (msg_t *msg_) ZMQ_FINAL; + int process_heartbeat_message (msg_t *msg_) ZMQ_FINAL; + int produce_pong_message (msg_t *msg_) ZMQ_FINAL; private: // Receive the greeting from the peer. diff --git a/unittests/unittest_ip_resolver.cpp b/unittests/unittest_ip_resolver.cpp index b50d6c75..3d1fa8c2 100644 --- a/unittests/unittest_ip_resolver.cpp +++ b/unittests/unittest_ip_resolver.cpp @@ -18,6 +18,7 @@ along with this program. If not, see . */ #include +#include "../src/macros.hpp" #include "../tests/testutil.hpp" #include "../tests/testutil_unity.hpp" #include "../unittests/unittest_resolver_common.hpp" @@ -39,7 +40,7 @@ void tearDown () { } -class test_ip_resolver_t : public zmq::ip_resolver_t +class test_ip_resolver_t ZMQ_FINAL : public zmq::ip_resolver_t { public: test_ip_resolver_t (zmq::ip_resolver_options_t opts_) : @@ -55,10 +56,10 @@ class test_ip_resolver_t : public zmq::ip_resolver_t const char *ipv6; }; - virtual int do_getaddrinfo (const char *node_, - const char *service_, - const struct addrinfo *hints_, - struct addrinfo **res_) + int do_getaddrinfo (const char *node_, + const char *service_, + const struct addrinfo *hints_, + struct addrinfo **res_) ZMQ_FINAL { static const struct dns_lut_t dns_lut[] = { {"ip.zeromq.org", "10.100.0.1", "fdf5:d058:d656::1"}, @@ -105,7 +106,7 @@ class test_ip_resolver_t : public zmq::ip_resolver_t return zmq::ip_resolver_t::do_getaddrinfo (ip, NULL, &ai, res_); } - virtual unsigned int do_if_nametoindex (const char *ifname_) + unsigned int do_if_nametoindex (const char *ifname_) ZMQ_FINAL { static const char *dummy_interfaces[] = { "lo0", diff --git a/unittests/unittest_poller.cpp b/unittests/unittest_poller.cpp index 7f800685..a7a7457a 100644 --- a/unittests/unittest_poller.cpp +++ b/unittests/unittest_poller.cpp @@ -63,7 +63,7 @@ struct test_events_t : zmq::i_poll_events (void) _fd; } - virtual void in_event () + void in_event () ZMQ_OVERRIDE { _poller.rm_fd (_handle); _handle = (zmq::poller_t::handle_t) NULL; @@ -73,13 +73,13 @@ struct test_events_t : zmq::i_poll_events } - virtual void out_event () + void out_event () ZMQ_OVERRIDE { // TODO } - virtual void timer_event (int id_) + void timer_event (int id_) ZMQ_OVERRIDE { LIBZMQ_UNUSED (id_); _poller.rm_fd (_handle);