mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-27 15:41:05 +08:00
Problem: non-modifying member functions not marked as const/static
Solution: add const/static
This commit is contained in:
parent
41e3f14d6a
commit
78961eeab7
@ -61,7 +61,7 @@ template <int ID = 0> class array_item_t
|
||||
|
||||
inline void set_array_index (int index_) { _array_index = index_; }
|
||||
|
||||
inline int get_array_index () { return _array_index; }
|
||||
inline int get_array_index () const { return _array_index; }
|
||||
|
||||
private:
|
||||
int _array_index;
|
||||
@ -118,7 +118,7 @@ template <typename T, int ID = 0> class array_t
|
||||
|
||||
inline void clear () { _items.clear (); }
|
||||
|
||||
inline size_type index (T *item_)
|
||||
static inline size_type index (T *item_)
|
||||
{
|
||||
return (size_type) ((item_t *) item_)->get_array_index ();
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ zmq::ctx_t::ctx_t () :
|
||||
#endif
|
||||
}
|
||||
|
||||
bool zmq::ctx_t::check_tag ()
|
||||
bool zmq::ctx_t::check_tag () const
|
||||
{
|
||||
return _tag == ZMQ_CTX_TAG_VALUE_GOOD;
|
||||
}
|
||||
@ -534,7 +534,7 @@ void zmq::ctx_t::destroy_socket (class socket_base_t *socket_)
|
||||
_reaper->stop ();
|
||||
}
|
||||
|
||||
zmq::object_t *zmq::ctx_t::get_reaper ()
|
||||
zmq::object_t *zmq::ctx_t::get_reaper () const
|
||||
{
|
||||
return _reaper;
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ class ctx_t ZMQ_FINAL : public thread_ctx_t
|
||||
ctx_t ();
|
||||
|
||||
// Returns false if object is not a context.
|
||||
bool check_tag ();
|
||||
bool check_tag () const;
|
||||
|
||||
// This function is called when user invokes zmq_ctx_term. If there are
|
||||
// no more sockets open it'll cause all the infrastructure to be shut
|
||||
@ -132,7 +132,7 @@ class ctx_t ZMQ_FINAL : public thread_ctx_t
|
||||
zmq::io_thread_t *choose_io_thread (uint64_t affinity_);
|
||||
|
||||
// Returns reaper thread object.
|
||||
zmq::object_t *get_reaper ();
|
||||
zmq::object_t *get_reaper () const;
|
||||
|
||||
// Management of inproc endpoints.
|
||||
int register_endpoint (const char *addr_, const endpoint_t &endpoint_);
|
||||
@ -253,7 +253,8 @@ class ctx_t ZMQ_FINAL : public thread_ctx_t
|
||||
connect_side,
|
||||
bind_side
|
||||
};
|
||||
void
|
||||
|
||||
static void
|
||||
connect_inproc_sockets (zmq::socket_base_t *bind_socket_,
|
||||
const options_t &bind_options_,
|
||||
const pending_connection_t &pending_connection_,
|
||||
|
@ -268,7 +268,7 @@ struct curve_client_tools_t
|
||||
size_t size_,
|
||||
const uint64_t cn_nonce_,
|
||||
const uint8_t *metadata_plaintext_,
|
||||
const size_t metadata_length_)
|
||||
const size_t metadata_length_) const
|
||||
{
|
||||
return produce_initiate (data_, size_, cn_nonce_, server_key,
|
||||
public_key, secret_key, cn_public, cn_secret,
|
||||
|
@ -73,7 +73,7 @@ class dist_t
|
||||
// Send the message to all the outbound pipes.
|
||||
int send_to_all (zmq::msg_t *msg_);
|
||||
|
||||
bool has_out ();
|
||||
static bool has_out ();
|
||||
|
||||
// check HWM of all pipes matching
|
||||
bool check_hwm ();
|
||||
|
@ -73,7 +73,7 @@ zmq::mailbox_t *zmq::io_thread_t::get_mailbox ()
|
||||
return &_mailbox;
|
||||
}
|
||||
|
||||
int zmq::io_thread_t::get_load ()
|
||||
int zmq::io_thread_t::get_load () const
|
||||
{
|
||||
return _poller->get_load ();
|
||||
}
|
||||
@ -107,7 +107,7 @@ void zmq::io_thread_t::timer_event (int)
|
||||
zmq_assert (false);
|
||||
}
|
||||
|
||||
zmq::poller_t *zmq::io_thread_t::get_poller ()
|
||||
zmq::poller_t *zmq::io_thread_t::get_poller () const
|
||||
{
|
||||
zmq_assert (_poller);
|
||||
return _poller;
|
||||
|
@ -67,13 +67,13 @@ class io_thread_t ZMQ_FINAL : public object_t, public i_poll_events
|
||||
void timer_event (int id_) ZMQ_FINAL;
|
||||
|
||||
// Used by io_objects to retrieve the associated poller object.
|
||||
poller_t *get_poller ();
|
||||
poller_t *get_poller () const;
|
||||
|
||||
// Command handlers.
|
||||
void process_stop () ZMQ_FINAL;
|
||||
|
||||
// Returns load experienced by the I/O thread.
|
||||
int get_load ();
|
||||
int get_load () const;
|
||||
|
||||
private:
|
||||
// I/O thread accesses incoming commands via this mailbox.
|
||||
|
@ -95,7 +95,7 @@ const char socket_type_scatter[] = "SCATTER";
|
||||
const char socket_type_dgram[] = "DGRAM";
|
||||
#endif
|
||||
|
||||
const char *zmq::mechanism_t::socket_type_string (int socket_type_) const
|
||||
const char *zmq::mechanism_t::socket_type_string (int socket_type_)
|
||||
{
|
||||
// TODO the order must of the names must correspond to the values resp. order of ZMQ_* socket type definitions in zmq.h!
|
||||
static const char *names[] = {
|
||||
|
@ -81,17 +81,20 @@ class mechanism_t
|
||||
|
||||
const blob_t &get_user_id () const;
|
||||
|
||||
const metadata_t::dict_t &get_zmtp_properties ()
|
||||
const metadata_t::dict_t &get_zmtp_properties () const
|
||||
{
|
||||
return _zmtp_properties;
|
||||
}
|
||||
|
||||
const metadata_t::dict_t &get_zap_properties () { return _zap_properties; }
|
||||
const metadata_t::dict_t &get_zap_properties () const
|
||||
{
|
||||
return _zap_properties;
|
||||
}
|
||||
|
||||
protected:
|
||||
// Only used to identify the socket for the Socket-Type
|
||||
// property in the wire protocol.
|
||||
const char *socket_type_string (int socket_type_) const;
|
||||
static const char *socket_type_string (int socket_type_);
|
||||
|
||||
static size_t add_property (unsigned char *ptr_,
|
||||
size_t ptr_capacity_,
|
||||
|
@ -39,7 +39,7 @@ zmq::mechanism_base_t::mechanism_base_t (session_base_t *const session_,
|
||||
{
|
||||
}
|
||||
|
||||
int zmq::mechanism_base_t::check_basic_command_structure (msg_t *msg_)
|
||||
int zmq::mechanism_base_t::check_basic_command_structure (msg_t *msg_) const
|
||||
{
|
||||
if (msg_->size () <= 1
|
||||
|| msg_->size () <= (static_cast<uint8_t *> (msg_->data ()))[0]) {
|
||||
|
@ -44,7 +44,7 @@ class mechanism_base_t : public mechanism_t
|
||||
|
||||
session_base_t *const session;
|
||||
|
||||
int check_basic_command_structure (msg_t *msg_);
|
||||
int check_basic_command_structure (msg_t *msg_) const;
|
||||
|
||||
void handle_error_reason (const char *error_reason_,
|
||||
size_t error_reason_len_);
|
||||
|
@ -553,7 +553,7 @@ bool zmq::msg_t::rm_refs (int refs_)
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t zmq::msg_t::get_routing_id ()
|
||||
uint32_t zmq::msg_t::get_routing_id () const
|
||||
{
|
||||
return _u.base.routing_id;
|
||||
}
|
||||
@ -574,7 +574,7 @@ int zmq::msg_t::reset_routing_id ()
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *zmq::msg_t::group ()
|
||||
const char *zmq::msg_t::group () const
|
||||
{
|
||||
return _u.base.group;
|
||||
}
|
||||
|
@ -146,10 +146,10 @@ class msg_t
|
||||
bool is_cmsg () const;
|
||||
bool is_lmsg () const;
|
||||
bool is_zcmsg () const;
|
||||
uint32_t get_routing_id ();
|
||||
uint32_t get_routing_id () const;
|
||||
int set_routing_id (uint32_t routing_id_);
|
||||
int reset_routing_id ();
|
||||
const char *group ();
|
||||
const char *group () const;
|
||||
int set_group (const char *group_);
|
||||
int set_group (const char *, size_t length_);
|
||||
|
||||
|
@ -53,7 +53,7 @@ zmq::object_t::~object_t ()
|
||||
{
|
||||
}
|
||||
|
||||
uint32_t zmq::object_t::get_tid ()
|
||||
uint32_t zmq::object_t::get_tid () const
|
||||
{
|
||||
return _tid;
|
||||
}
|
||||
@ -63,7 +63,7 @@ void zmq::object_t::set_tid (uint32_t id_)
|
||||
_tid = id_;
|
||||
}
|
||||
|
||||
zmq::ctx_t *zmq::object_t::get_ctx ()
|
||||
zmq::ctx_t *zmq::object_t::get_ctx () const
|
||||
{
|
||||
return _ctx;
|
||||
}
|
||||
@ -184,7 +184,7 @@ void zmq::object_t::unregister_endpoints (socket_base_t *socket_)
|
||||
return _ctx->unregister_endpoints (socket_);
|
||||
}
|
||||
|
||||
zmq::endpoint_t zmq::object_t::find_endpoint (const char *addr_)
|
||||
zmq::endpoint_t zmq::object_t::find_endpoint (const char *addr_) const
|
||||
{
|
||||
return _ctx->find_endpoint (addr_);
|
||||
}
|
||||
@ -207,7 +207,7 @@ void zmq::object_t::destroy_socket (socket_base_t *socket_)
|
||||
_ctx->destroy_socket (socket_);
|
||||
}
|
||||
|
||||
zmq::io_thread_t *zmq::object_t::choose_io_thread (uint64_t affinity_)
|
||||
zmq::io_thread_t *zmq::object_t::choose_io_thread (uint64_t affinity_) const
|
||||
{
|
||||
return _ctx->choose_io_thread (affinity_);
|
||||
}
|
||||
|
@ -59,9 +59,9 @@ class object_t
|
||||
object_t (object_t *parent_);
|
||||
virtual ~object_t ();
|
||||
|
||||
uint32_t get_tid ();
|
||||
uint32_t get_tid () const;
|
||||
void set_tid (uint32_t id_);
|
||||
ctx_t *get_ctx ();
|
||||
ctx_t *get_ctx () const;
|
||||
void process_command (const zmq::command_t &cmd_);
|
||||
void send_inproc_connected (zmq::socket_base_t *socket_);
|
||||
void send_bind (zmq::own_t *destination_,
|
||||
@ -74,7 +74,7 @@ class object_t
|
||||
int register_endpoint (const char *addr_, const zmq::endpoint_t &endpoint_);
|
||||
int unregister_endpoint (const std::string &addr_, socket_base_t *socket_);
|
||||
void unregister_endpoints (zmq::socket_base_t *socket_);
|
||||
zmq::endpoint_t find_endpoint (const char *addr_);
|
||||
zmq::endpoint_t find_endpoint (const char *addr_) const;
|
||||
void pend_connection (const std::string &addr_,
|
||||
const endpoint_t &endpoint_,
|
||||
pipe_t **pipes_);
|
||||
@ -86,7 +86,7 @@ class object_t
|
||||
void log (const char *format_, ...);
|
||||
|
||||
// Chooses least loaded I/O thread.
|
||||
zmq::io_thread_t *choose_io_thread (uint64_t affinity_);
|
||||
zmq::io_thread_t *choose_io_thread (uint64_t affinity_) const;
|
||||
|
||||
// Derived object can use these functions to send commands
|
||||
// to other objects.
|
||||
|
@ -147,7 +147,7 @@ void zmq::own_t::terminate ()
|
||||
send_term_req (_owner, this);
|
||||
}
|
||||
|
||||
bool zmq::own_t::is_terminating ()
|
||||
bool zmq::own_t::is_terminating () const
|
||||
{
|
||||
return _terminating;
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ class own_t : public object_t
|
||||
void terminate ();
|
||||
|
||||
// Returns true if the object is in process of termination.
|
||||
bool is_terminating ();
|
||||
bool is_terminating () const;
|
||||
|
||||
// Derived object destroys own_t. There's no point in allowing
|
||||
// others to invoke the destructor. At the same time, it has to be
|
||||
|
@ -192,7 +192,7 @@ int zmq::plain_server_t::process_hello (msg_t *msg_)
|
||||
return receive_and_process_zap_reply () == -1 ? -1 : 0;
|
||||
}
|
||||
|
||||
void zmq::plain_server_t::produce_welcome (msg_t *msg_) const
|
||||
void zmq::plain_server_t::produce_welcome (msg_t *msg_)
|
||||
{
|
||||
const int rc = msg_->init_size (welcome_prefix_len);
|
||||
errno_assert (rc == 0);
|
||||
|
@ -51,7 +51,7 @@ class plain_server_t ZMQ_FINAL : public zap_client_common_handshake_t
|
||||
int process_handshake_command (msg_t *msg_) ZMQ_FINAL;
|
||||
|
||||
private:
|
||||
void produce_welcome (msg_t *msg_) const;
|
||||
static void produce_welcome (msg_t *msg_);
|
||||
void produce_ready (msg_t *msg_) const;
|
||||
void produce_error (msg_t *msg_) const;
|
||||
|
||||
|
@ -123,7 +123,7 @@ void zmq::worker_poller_base_t::start (const char *name_)
|
||||
_ctx.start_thread (_worker, worker_routine, this, name_);
|
||||
}
|
||||
|
||||
void zmq::worker_poller_base_t::check_thread ()
|
||||
void zmq::worker_poller_base_t::check_thread () const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
zmq_assert (!_worker.get_started () || _worker.is_current_thread ());
|
||||
|
@ -172,7 +172,7 @@ class worker_poller_base_t : public poller_base_t
|
||||
// via an assertion.
|
||||
// Should be called by the add_fd, removed_fd, set_*, reset_* functions
|
||||
// to ensure correct usage.
|
||||
void check_thread ();
|
||||
void check_thread () const;
|
||||
|
||||
// Stops the worker thread. Should be called from the destructor of the
|
||||
// leaf class.
|
||||
|
@ -325,7 +325,7 @@ void zmq::session_base_t::hiccuped (pipe_t *)
|
||||
zmq_assert (false);
|
||||
}
|
||||
|
||||
zmq::socket_base_t *zmq::session_base_t::get_socket ()
|
||||
zmq::socket_base_t *zmq::session_base_t::get_socket () const
|
||||
{
|
||||
return _socket;
|
||||
}
|
||||
@ -385,7 +385,7 @@ int zmq::session_base_t::zap_connect ()
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool zmq::session_base_t::zap_enabled ()
|
||||
bool zmq::session_base_t::zap_enabled () const
|
||||
{
|
||||
return (options.mechanism != ZMQ_NULL || !options.zap_domain.empty ());
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ class session_base_t : public own_t, public io_object_t, public i_pipe_events
|
||||
virtual int push_msg (msg_t *msg_);
|
||||
|
||||
int zap_connect ();
|
||||
bool zap_enabled ();
|
||||
bool zap_enabled () const;
|
||||
|
||||
// Fetches a message. Returns 0 if successful; -1 otherwise.
|
||||
// The caller is responsible for freeing the message when no
|
||||
@ -92,7 +92,7 @@ class session_base_t : public own_t, public io_object_t, public i_pipe_events
|
||||
// The function takes ownership of the message.
|
||||
int write_zap_msg (msg_t *msg_);
|
||||
|
||||
socket_base_t *get_socket ();
|
||||
socket_base_t *get_socket () const;
|
||||
const endpoint_uri_pair_t &get_endpoint () const;
|
||||
|
||||
protected:
|
||||
|
@ -227,7 +227,7 @@ void zmq::signaler_t::send ()
|
||||
#endif
|
||||
}
|
||||
|
||||
int zmq::signaler_t::wait (int timeout_)
|
||||
int zmq::signaler_t::wait (int timeout_) const
|
||||
{
|
||||
#ifdef HAVE_FORK
|
||||
if (unlikely (pid != getpid ())) {
|
||||
|
@ -54,7 +54,7 @@ class signaler_t
|
||||
// May return retired_fd if the signaler could not be initialized.
|
||||
fd_t get_fd () const;
|
||||
void send ();
|
||||
int wait (int timeout_);
|
||||
int wait (int timeout_) const;
|
||||
void recv ();
|
||||
int recv_failable ();
|
||||
|
||||
|
@ -81,12 +81,12 @@ zmq::socket_poller_t::~socket_poller_t ()
|
||||
#endif
|
||||
}
|
||||
|
||||
bool zmq::socket_poller_t::check_tag ()
|
||||
bool zmq::socket_poller_t::check_tag () const
|
||||
{
|
||||
return _tag == 0xCAFEBABE;
|
||||
}
|
||||
|
||||
int zmq::socket_poller_t::signaler_fd (fd_t *fd_)
|
||||
int zmq::socket_poller_t::signaler_fd (fd_t *fd_) const
|
||||
{
|
||||
if (_signaler) {
|
||||
*fd_ = _signaler->get_fd ();
|
||||
|
@ -76,19 +76,19 @@ class socket_poller_t
|
||||
int modify_fd (fd_t fd_, short events_);
|
||||
int remove_fd (fd_t fd_);
|
||||
// Returns the signaler's fd if there is one, otherwise errors.
|
||||
int signaler_fd (fd_t *fd_);
|
||||
int signaler_fd (fd_t *fd_) const;
|
||||
|
||||
int wait (event_t *events_, int n_events_, long timeout_);
|
||||
|
||||
inline int size () { return static_cast<int> (_items.size ()); };
|
||||
inline int size () const { return static_cast<int> (_items.size ()); };
|
||||
|
||||
// Return false if object is not a socket.
|
||||
bool check_tag ();
|
||||
bool check_tag () const;
|
||||
|
||||
private:
|
||||
void zero_trail_events (zmq::socket_poller_t::event_t *events_,
|
||||
int n_events_,
|
||||
int found_);
|
||||
static void zero_trail_events (zmq::socket_poller_t::event_t *events_,
|
||||
int n_events_,
|
||||
int found_);
|
||||
#if defined ZMQ_POLL_BASED_ON_POLL
|
||||
int check_events (zmq::socket_poller_t::event_t *events_, int n_events_);
|
||||
#elif defined ZMQ_POLL_BASED_ON_SELECT
|
||||
@ -98,11 +98,11 @@ class socket_poller_t
|
||||
fd_set &outset_,
|
||||
fd_set &errset_);
|
||||
#endif
|
||||
int adjust_timeout (zmq::clock_t &clock_,
|
||||
long timeout_,
|
||||
uint64_t &now_,
|
||||
uint64_t &end_,
|
||||
bool &first_pass_);
|
||||
static int adjust_timeout (zmq::clock_t &clock_,
|
||||
long timeout_,
|
||||
uint64_t &now_,
|
||||
uint64_t &end_,
|
||||
bool &first_pass_);
|
||||
int rebuild ();
|
||||
|
||||
// Used to check whether the object is a socket_poller.
|
||||
|
@ -344,7 +344,7 @@ int zmq::socks_connecter_t::connect_to_proxy ()
|
||||
return -1;
|
||||
}
|
||||
|
||||
zmq::fd_t zmq::socks_connecter_t::check_proxy_connection ()
|
||||
zmq::fd_t zmq::socks_connecter_t::check_proxy_connection () const
|
||||
{
|
||||
// Async connect has finished. Check whether an error occurred
|
||||
int err = 0;
|
||||
|
@ -88,13 +88,13 @@ class socks_connecter_t ZMQ_FINAL : public stream_connecter_base_t
|
||||
// Internal function to start the actual connection establishment.
|
||||
void start_connecting () ZMQ_FINAL;
|
||||
|
||||
int process_server_response (const socks_choice_t &response_);
|
||||
int process_server_response (const socks_response_t &response_);
|
||||
int process_server_response (const socks_auth_response_t &response_);
|
||||
static int process_server_response (const socks_choice_t &response_);
|
||||
static int process_server_response (const socks_response_t &response_);
|
||||
static int process_server_response (const socks_auth_response_t &response_);
|
||||
|
||||
int parse_address (const std::string &address_,
|
||||
std::string &hostname_,
|
||||
uint16_t &port_);
|
||||
static int parse_address (const std::string &address_,
|
||||
std::string &hostname_,
|
||||
uint16_t &port_);
|
||||
|
||||
int connect_to_proxy ();
|
||||
|
||||
@ -107,7 +107,7 @@ class socks_connecter_t ZMQ_FINAL : public stream_connecter_base_t
|
||||
|
||||
// Get the file descriptor of newly created connection. Returns
|
||||
// retired_fd if the connection was unsuccessful.
|
||||
zmq::fd_t check_proxy_connection ();
|
||||
zmq::fd_t check_proxy_connection () const;
|
||||
|
||||
socks_greeting_encoder_t _greeting_encoder;
|
||||
socks_choice_decoder_t _choice_decoder;
|
||||
|
@ -43,7 +43,7 @@ zmq::timers_t::~timers_t ()
|
||||
_tag = 0xdeadbeef;
|
||||
}
|
||||
|
||||
bool zmq::timers_t::check_tag ()
|
||||
bool zmq::timers_t::check_tag () const
|
||||
{
|
||||
return _tag == 0xCAFEDADA;
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ class timers_t
|
||||
int execute ();
|
||||
|
||||
// Return false if object is not a timers class.
|
||||
bool check_tag ();
|
||||
bool check_tag () const;
|
||||
|
||||
private:
|
||||
// Used to check whether the object is a timers class.
|
||||
|
@ -48,14 +48,14 @@ class udp_engine_t ZMQ_FINAL : public io_object_t, public i_engine
|
||||
|
||||
private:
|
||||
int resolve_raw_address (const char *name_, size_t length_);
|
||||
void sockaddr_to_msg (zmq::msg_t *msg_, const sockaddr_in *addr_);
|
||||
static void sockaddr_to_msg (zmq::msg_t *msg_, const sockaddr_in *addr_);
|
||||
|
||||
int set_udp_reuse_address (fd_t s_, bool on_);
|
||||
int set_udp_reuse_port (fd_t s_, bool on_);
|
||||
static int set_udp_reuse_address (fd_t s_, bool on_);
|
||||
static int set_udp_reuse_port (fd_t s_, bool on_);
|
||||
// Indicate, if the multicast data being sent should be looped back
|
||||
int set_udp_multicast_loop (fd_t s_, bool is_ipv6_, bool loop_);
|
||||
static int set_udp_multicast_loop (fd_t s_, bool is_ipv6_, bool loop_);
|
||||
// Set multicast TTL
|
||||
int set_udp_multicast_ttl (fd_t s_, bool is_ipv6_, int hops_);
|
||||
static int set_udp_multicast_ttl (fd_t s_, bool is_ipv6_, int hops_);
|
||||
// Set multicast address/interface
|
||||
int set_udp_multicast_iface (fd_t s_,
|
||||
bool is_ipv6_,
|
||||
|
@ -179,7 +179,7 @@ template <typename T, int N> class yqueue_t
|
||||
chunk_t *next;
|
||||
};
|
||||
|
||||
inline chunk_t *allocate_chunk ()
|
||||
static inline chunk_t *allocate_chunk ()
|
||||
{
|
||||
#ifdef HAVE_POSIX_MEMALIGN
|
||||
void *pv;
|
||||
|
Loading…
x
Reference in New Issue
Block a user