diff options
author | Martin Sustrik <sustrik@250bpm.com> | 2012-04-13 09:34:13 +0200 |
---|---|---|
committer | Martin Sustrik <sustrik@250bpm.com> | 2012-04-14 05:21:09 +0200 |
commit | 19894e0a1b6fbbcb62028fc6513ef3904a6f5c76 (patch) | |
tree | 365270e76f29acca4d60f66773c3ec375e413a85 /src/sub.hpp | |
parent | 4f120cb103db3987e01ece48648c844218b91ff2 (diff) |
Separate subscription forwarding from SUB-side filtering
- subscription forwarding is handled by XSUB socket
- filtering is handled by SUB sockets
- subscriptions are decoupled from filter engines
- filter doesn't have to be able to enumarate the subscriptions
(no sf_enumerate function)
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src/sub.hpp')
-rw-r--r-- | src/sub.hpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/sub.hpp b/src/sub.hpp index 47b1877..4c3bf7f 100644 --- a/src/sub.hpp +++ b/src/sub.hpp @@ -22,6 +22,10 @@ #ifndef __XS_SUB_HPP_INCLUDED__ #define __XS_SUB_HPP_INCLUDED__ +#include <vector> + +#include "../include/xs.h" + #include "xsub.hpp" namespace xs @@ -43,10 +47,33 @@ namespace xs int xsetsockopt (int option_, const void *optval_, size_t optvallen_); int xsend (xs::msg_t *msg_, int flags_); + int xrecv (xs::msg_t *msg_, int flags_); + bool xhas_in (); bool xhas_out (); + // The repository of subscriptions. + struct filter_t + { + xs_filter_t *type; + void *instance; + }; + typedef std::vector <filter_t> filters_t; + filters_t filters; + + // If true, part of a multipart message was already received, but + // there are following parts still waiting. + bool more; + + // If true, 'message' contains a matching message to return on the + // next recv call. + bool has_message; + msg_t message; + private: + // Check whether the message matches at least one subscription. + bool match (xs::msg_t *msg_); + sub_t (const sub_t&); const sub_t &operator = (const sub_t&); }; |