summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@fastmq.commkdir>2009-08-30 08:18:31 +0200
committerMartin Sustrik <sustrik@fastmq.commkdir>2009-08-30 08:18:31 +0200
commit176879e5bbce6115ff5741f2426f689bda312109 (patch)
tree295d25e283b37c66497743fb33665d128ad03218 /src
parent1d650934e477be32db9a3c64de077deed0416689 (diff)
engine virtualised; chatroom example removed
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am1
-rw-r--r--src/command.hpp2
-rw-r--r--src/i_engine.hpp43
-rw-r--r--src/object.cpp5
-rw-r--r--src/object.hpp4
-rw-r--r--src/owned.cpp2
-rw-r--r--src/owned.hpp2
-rw-r--r--src/session.cpp4
-rw-r--r--src/session.hpp4
-rw-r--r--src/zmq_engine.hpp9
10 files changed, 59 insertions, 17 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index b6a4540..1dac30d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -20,6 +20,7 @@ libzmq_la_SOURCES = \
io_thread.hpp \
ip.hpp \
i_endpoint.hpp \
+ i_engine.hpp \
i_poller.hpp \
i_poll_events.hpp \
i_signaler.hpp \
diff --git a/src/command.hpp b/src/command.hpp
index d16d4fa..9a2e5d5 100644
--- a/src/command.hpp
+++ b/src/command.hpp
@@ -65,7 +65,7 @@ namespace zmq
// Attach the engine to the session.
struct {
- class zmq_engine_t *engine;
+ struct i_engine *engine;
} attach;
// Sent from session to socket to establish pipe(s) between them.
diff --git a/src/i_engine.hpp b/src/i_engine.hpp
new file mode 100644
index 0000000..c21556f
--- /dev/null
+++ b/src/i_engine.hpp
@@ -0,0 +1,43 @@
+/*
+ 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_ENGINE_HPP_INCLUDED__
+#define __ZMQ_I_ENGINE_HPP_INCLUDED__
+
+namespace zmq
+{
+
+ struct i_engine
+ {
+ virtual ~i_engine () {}
+
+ // Plug the engine to the session.
+ virtual void plug (struct i_inout *inout_) = 0;
+
+ // Unplug the engine from the session.
+ virtual void unplug () = 0;
+
+ // This method is called by the session to signalise that there
+ // are messages to send available.
+ virtual void revive () = 0;
+ };
+
+}
+
+#endif
diff --git a/src/object.cpp b/src/object.cpp
index b3cf898..c0ef21c 100644
--- a/src/object.cpp
+++ b/src/object.cpp
@@ -26,7 +26,6 @@
#include "owned.hpp"
#include "session.hpp"
#include "socket_base.hpp"
-#include "zmq_engine.hpp" // TODO: remove this line
zmq::object_t::object_t (dispatcher_t *dispatcher_, int thread_slot_) :
dispatcher (dispatcher_),
@@ -153,7 +152,7 @@ void zmq::object_t::send_own (socket_base_t *destination_, owned_t *object_)
send_command (cmd);
}
-void zmq::object_t::send_attach (session_t *destination_, zmq_engine_t *engine_)
+void zmq::object_t::send_attach (session_t *destination_, i_engine *engine_)
{
// The assumption here is that command sequence number of the destination
// object was already incremented in find_session function.
@@ -241,7 +240,7 @@ void zmq::object_t::process_own (owned_t *object_)
zmq_assert (false);
}
-void zmq::object_t::process_attach (zmq_engine_t *engine_)
+void zmq::object_t::process_attach (i_engine *engine_)
{
zmq_assert (false);
}
diff --git a/src/object.hpp b/src/object.hpp
index 8ce569e..250e856 100644
--- a/src/object.hpp
+++ b/src/object.hpp
@@ -60,7 +60,7 @@ namespace zmq
void send_own (class socket_base_t *destination_,
class owned_t *object_);
void send_attach (class session_t *destination_,
- class zmq_engine_t *engine_);
+ struct i_engine *engine_);
void send_bind (object_t *destination_, class owned_t *session_,
class reader_t *in_pipe_, class writer_t *out_pipe_);
void send_revive (class object_t *destination_);
@@ -76,7 +76,7 @@ namespace zmq
virtual void process_stop ();
virtual void process_plug ();
virtual void process_own (class owned_t *object_);
- virtual void process_attach (class zmq_engine_t *engine_);
+ virtual void process_attach (struct i_engine *engine_);
virtual void process_bind (class owned_t *session_,
class reader_t *in_pipe_, class writer_t *out_pipe_);
virtual void process_revive ();
diff --git a/src/owned.cpp b/src/owned.cpp
index 810bed7..a534dd3 100644
--- a/src/owned.cpp
+++ b/src/owned.cpp
@@ -47,7 +47,7 @@ void zmq::owned_t::process_plug ()
finalise_command ();
}
-void zmq::owned_t::process_attach (zmq_engine_t *engine_)
+void zmq::owned_t::process_attach (struct i_engine *engine_)
{
// Keep track of how many commands were processed so far.
processed_seqnum++;
diff --git a/src/owned.hpp b/src/owned.hpp
index 78036a3..c56ea49 100644
--- a/src/owned.hpp
+++ b/src/owned.hpp
@@ -61,7 +61,7 @@ namespace zmq
// It's vital that session invokes io_object_t::process_attach
// at the end of it's own attach handler.
- void process_attach (class zmq_engine_t *engine_);
+ void process_attach (struct i_engine *engine_);
// io_object_t defines a new handler used to disconnect the object
// from the poller object. Implement the handlen in the derived
diff --git a/src/session.cpp b/src/session.cpp
index d667851..f562bd5 100644
--- a/src/session.cpp
+++ b/src/session.cpp
@@ -18,7 +18,7 @@
*/
#include "session.hpp"
-#include "zmq_engine.hpp"
+#include "i_engine.hpp"
#include "err.hpp"
#include "pipe.hpp"
@@ -149,7 +149,7 @@ void zmq::session_t::process_unplug ()
}
}
-void zmq::session_t::process_attach (class zmq_engine_t *engine_)
+void zmq::session_t::process_attach (i_engine *engine_)
{
zmq_assert (engine_);
engine = engine_;
diff --git a/src/session.hpp b/src/session.hpp
index ba5bcdd..46699cf 100644
--- a/src/session.hpp
+++ b/src/session.hpp
@@ -58,7 +58,7 @@ namespace zmq
// Handlers for incoming commands.
void process_plug ();
void process_unplug ();
- void process_attach (class zmq_engine_t *engine_);
+ void process_attach (struct i_engine *engine_);
// Inbound pipe, i.e. one the session is getting messages from.
class reader_t *in_pipe;
@@ -69,7 +69,7 @@ namespace zmq
// Outbound pipe, i.e. one the socket is sending messages to.
class writer_t *out_pipe;
- class zmq_engine_t *engine;
+ struct i_engine *engine;
// The name of the session. One that is used to register it with
// socket-level repository of sessions.
diff --git a/src/zmq_engine.hpp b/src/zmq_engine.hpp
index ba25ded..8299ebf 100644
--- a/src/zmq_engine.hpp
+++ b/src/zmq_engine.hpp
@@ -20,6 +20,7 @@
#ifndef __ZMQ_ZMQ_ENGINE_HPP_INCLUDED__
#define __ZMQ_ZMQ_ENGINE_HPP_INCLUDED__
+#include "i_engine.hpp"
#include "io_object.hpp"
#include "tcp_socket.hpp"
#include "zmq_encoder.hpp"
@@ -28,24 +29,22 @@
namespace zmq
{
- class zmq_engine_t : public io_object_t
+ class zmq_engine_t : public io_object_t, public i_engine
{
public:
zmq_engine_t (class io_thread_t *parent_, fd_t fd_);
~zmq_engine_t ();
+ // i_engine interface implementation.
void plug (struct i_inout *inout_);
void unplug ();
+ void revive ();
// i_poll_events interface implementation.
void in_event ();
void out_event ();
- // This method is called by the session to signalise that there
- // are messages to send available.
- void revive ();
-
private:
// Function to handle network disconnections.