Commit bda766ab authored by Martin Sustrik's avatar Martin Sustrik

redundant interface (i_api) removed

parent 9f1f823b
...@@ -18,11 +18,9 @@ libzmq_la_SOURCES = \ ...@@ -18,11 +18,9 @@ libzmq_la_SOURCES = \
io_object.hpp \ io_object.hpp \
io_thread.hpp \ io_thread.hpp \
ip.hpp \ ip.hpp \
i_api.hpp \
i_poller.hpp \ i_poller.hpp \
i_poll_events.hpp \ i_poll_events.hpp \
i_signaler.hpp \ i_signaler.hpp \
i_socket.hpp \
kqueue.hpp \ kqueue.hpp \
msg.hpp \ msg.hpp \
mutex.hpp \ mutex.hpp \
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#endif #endif
#include "app_thread.hpp" #include "app_thread.hpp"
#include "i_api.hpp"
#include "dispatcher.hpp" #include "dispatcher.hpp"
#include "err.hpp" #include "err.hpp"
#include "pipe.hpp" #include "pipe.hpp"
...@@ -130,7 +129,7 @@ void zmq::app_thread_t::process_commands (bool block_) ...@@ -130,7 +129,7 @@ void zmq::app_thread_t::process_commands (bool block_)
} }
} }
zmq::i_api *zmq::app_thread_t::create_socket (int type_) zmq::socket_base_t *zmq::app_thread_t::create_socket (int type_)
{ {
// TODO: type is ignored for the time being. // TODO: type is ignored for the time being.
socket_base_t *s = new socket_base_t (this); socket_base_t *s = new socket_base_t (this);
...@@ -139,7 +138,7 @@ zmq::i_api *zmq::app_thread_t::create_socket (int type_) ...@@ -139,7 +138,7 @@ zmq::i_api *zmq::app_thread_t::create_socket (int type_)
return s; return s;
} }
void zmq::app_thread_t::remove_socket (i_api *socket_) void zmq::app_thread_t::remove_socket (socket_base_t *socket_)
{ {
// TODO: To speed this up we can possibly use the system where each socket // TODO: To speed this up we can possibly use the system where each socket
// holds its index (see I/O scheduler implementation). // holds its index (see I/O scheduler implementation).
......
...@@ -56,15 +56,15 @@ namespace zmq ...@@ -56,15 +56,15 @@ namespace zmq
void process_commands (bool block_); void process_commands (bool block_);
// Create a socket of a specified type. // Create a socket of a specified type.
struct i_api *create_socket (int type_); class socket_base_t *create_socket (int type_);
// Unregister the socket from the app_thread (called by socket itself). // Unregister the socket from the app_thread (called by socket itself).
void remove_socket (struct i_api *socket_); void remove_socket (class socket_base_t *socket_);
private: private:
// All the sockets created from this application thread. // All the sockets created from this application thread.
typedef std::vector <struct i_api*> sockets_t; typedef std::vector <class socket_base_t*> sockets_t;
sockets_t sockets; sockets_t sockets;
// Thread ID associated with this slot. // Thread ID associated with this slot.
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "../include/zmq.h" #include "../include/zmq.h"
#include "dispatcher.hpp" #include "dispatcher.hpp"
#include "i_api.hpp"
#include "app_thread.hpp" #include "app_thread.hpp"
#include "io_thread.hpp" #include "io_thread.hpp"
#include "platform.hpp" #include "platform.hpp"
...@@ -98,7 +97,7 @@ int zmq::dispatcher_t::thread_slot_count () ...@@ -98,7 +97,7 @@ int zmq::dispatcher_t::thread_slot_count ()
return signalers.size (); return signalers.size ();
} }
zmq::i_api *zmq::dispatcher_t::create_socket (int type_) zmq::socket_base_t *zmq::dispatcher_t::create_socket (int type_)
{ {
threads_sync.lock (); threads_sync.lock ();
app_thread_t *thread = choose_app_thread (); app_thread_t *thread = choose_app_thread ();
......
...@@ -55,7 +55,7 @@ namespace zmq ...@@ -55,7 +55,7 @@ namespace zmq
~dispatcher_t (); ~dispatcher_t ();
// Create a socket. // Create a socket.
struct i_api *create_socket (int type_); class socket_base_t *create_socket (int type_);
// Returns number of thread slots in the dispatcher. To be used by // Returns number of thread slots in the dispatcher. To be used by
// individual threads to find out how many distinct signals can be // individual threads to find out how many distinct signals can be
......
/*
Copyright (c) 2007-2009 FastMQ Inc.
This file is part of 0MQ.
0MQ is free software; you can redistribute it and/or modify it under
the terms of the Lesser GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
0MQ is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Lesser GNU General Public License for more details.
You should have received a copy of the Lesser GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __ZMQ_I_API_HPP_INCLUDED__
#define __ZMQ_I_API_HPP_INCLUDED__
namespace zmq
{
struct i_api
{
virtual ~i_api () {}
virtual int setsockopt (int option_, void *optval_,
size_t optvallen_) = 0;
virtual int bind (const char *addr_) = 0;
virtual int connect (const char *addr_) = 0;
virtual int subscribe (const char *criteria_) = 0;
virtual int send (struct zmq_msg *msg_, int flags_) = 0;
virtual int flush () = 0;
virtual int recv (struct zmq_msg *msg_, int flags_) = 0;
virtual int close () = 0;
};
}
#endif
/* /*
Copyright (c) 2007-2009 FastMQ Inc. Copyright (c) 2007-2009 FastMQ Inc.
This file is part of 0MQ. This file is part of 0MQ.
0MQ is free software; you can redistribute it and/or modify it under 0MQ is free software; you can redistribute it and/or modify it under
the terms of the Lesser GNU General Public License as published by the terms of the Lesser GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or the Free Software Foundation; either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
0MQ is distributed in the hope that it will be useful, 0MQ is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Lesser GNU General Public License for more details. Lesser GNU General Public License for more details.
You should have received a copy of the Lesser GNU General Public License You should have received a copy of the Lesser GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef __ZMQ_I_POLL_EVENTS_HPP_INCLUDED__ #ifndef __ZMQ_I_POLL_EVENTS_HPP_INCLUDED__
......
...@@ -23,29 +23,28 @@ ...@@ -23,29 +23,28 @@
#include <set> #include <set>
#include <string> #include <string>
#include "i_api.hpp"
#include "object.hpp" #include "object.hpp"
#include "stdint.hpp" #include "stdint.hpp"
namespace zmq namespace zmq
{ {
class socket_base_t : public object_t, public i_api class socket_base_t : public object_t
{ {
public: public:
socket_base_t (class app_thread_t *parent_); socket_base_t (class app_thread_t *parent_);
~socket_base_t (); ~socket_base_t ();
// i_api interface implementation. // Interface for communication with the API layer.
int setsockopt (int option_, void *optval_, size_t optvallen_); virtual int setsockopt (int option_, void *optval_, size_t optvallen_);
int bind (const char *addr_); virtual int bind (const char *addr_);
int connect (const char *addr_); virtual int connect (const char *addr_);
int subscribe (const char *criteria_); virtual int subscribe (const char *criteria_);
int send (struct zmq_msg *msg_, int flags_); virtual int send (struct zmq_msg *msg_, int flags_);
int flush (); virtual int flush ();
int recv (struct zmq_msg *msg_, int flags_); virtual int recv (struct zmq_msg *msg_, int flags_);
int close (); virtual int close ();
private: private:
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <new> #include <new>
#include "i_api.hpp" #include "socket_base.hpp"
#include "err.hpp" #include "err.hpp"
#include "dispatcher.hpp" #include "dispatcher.hpp"
#include "msg.hpp" #include "msg.hpp"
...@@ -188,41 +188,42 @@ void *zmq_socket (void *dispatcher_, int type_) ...@@ -188,41 +188,42 @@ void *zmq_socket (void *dispatcher_, int type_)
int zmq_close (void *s_) int zmq_close (void *s_)
{ {
((zmq::i_api*) s_)->close (); ((zmq::socket_base_t*) s_)->close ();
return 0; return 0;
} }
int zmq_setsockopt (void *s_, int option_, void *optval_, size_t optvallen_) int zmq_setsockopt (void *s_, int option_, void *optval_, size_t optvallen_)
{ {
return (((zmq::i_api*) s_)->setsockopt (option_, optval_, optvallen_)); return (((zmq::socket_base_t*) s_)->setsockopt (option_, optval_,
optvallen_));
} }
int zmq_bind (void *s_, const char *addr_) int zmq_bind (void *s_, const char *addr_)
{ {
return (((zmq::i_api*) s_)->bind (addr_)); return (((zmq::socket_base_t*) s_)->bind (addr_));
} }
int zmq_connect (void *s_, const char *addr_) int zmq_connect (void *s_, const char *addr_)
{ {
return (((zmq::i_api*) s_)->connect (addr_)); return (((zmq::socket_base_t*) s_)->connect (addr_));
} }
int zmq_subscribe (void *s_, const char *criteria_) int zmq_subscribe (void *s_, const char *criteria_)
{ {
return (((zmq::i_api*) s_)->subscribe (criteria_)); return (((zmq::socket_base_t*) s_)->subscribe (criteria_));
} }
int zmq_send (void *s_, zmq_msg *msg_, int flags_) int zmq_send (void *s_, zmq_msg *msg_, int flags_)
{ {
return (((zmq::i_api*) s_)->send (msg_, flags_)); return (((zmq::socket_base_t*) s_)->send (msg_, flags_));
} }
int zmq_flush (void *s_) int zmq_flush (void *s_)
{ {
return (((zmq::i_api*) s_)->flush ()); return (((zmq::socket_base_t*) s_)->flush ());
} }
int zmq_recv (void *s_, zmq_msg *msg_, int flags_) int zmq_recv (void *s_, zmq_msg *msg_, int flags_)
{ {
return (((zmq::i_api*) s_)->recv (msg_, flags_)); return (((zmq::socket_base_t*) s_)->recv (msg_, flags_));
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment