~ubuntu-branches/ubuntu/precise/zeromq/precise

« back to all changes in this revision

Viewing changes to src/xsub.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Martin Lucina
  • Date: 2011-05-13 12:43:09 UTC
  • mfrom: (7.2.1 sid)
  • Revision ID: james.westby@ubuntu.com-20110513124309-m3gdt964ga67rcwu
Tags: 2.1.7-1
* New upstream version. (closes: #619374)
* --with-system-pgm is now used instead of the embedded OpenPGM library. 
* Added Debian watch file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright (c) 2007-2011 iMatix Corporation
 
3
    Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
 
4
 
 
5
    This file is part of 0MQ.
 
6
 
 
7
    0MQ is free software; you can redistribute it and/or modify it under
 
8
    the terms of the GNU Lesser General Public License as published by
 
9
    the Free Software Foundation; either version 3 of the License, or
 
10
    (at your option) any later version.
 
11
 
 
12
    0MQ is distributed in the hope that it will be useful,
 
13
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
    GNU Lesser General Public License for more details.
 
16
 
 
17
    You should have received a copy of the GNU Lesser General Public License
 
18
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
*/
 
20
 
 
21
#ifndef __ZMQ_XSUB_HPP_INCLUDED__
 
22
#define __ZMQ_XSUB_HPP_INCLUDED__
 
23
 
 
24
#include "../include/zmq.h"
 
25
 
 
26
#include "trie.hpp"
 
27
#include "socket_base.hpp"
 
28
#include "fq.hpp"
 
29
 
 
30
namespace zmq
 
31
{
 
32
 
 
33
    class xsub_t : public socket_base_t
 
34
    {
 
35
    public:
 
36
 
 
37
        xsub_t (class ctx_t *parent_, uint32_t tid_);
 
38
        ~xsub_t ();
 
39
 
 
40
    protected:
 
41
 
 
42
        //  Overloads of functions from socket_base_t.
 
43
        void xattach_pipes (class reader_t *inpipe_, class writer_t *outpipe_,
 
44
            const blob_t &peer_identity_);
 
45
        int xsend (zmq_msg_t *msg_, int options_);
 
46
        bool xhas_out ();
 
47
        int xrecv (zmq_msg_t *msg_, int flags_);
 
48
        bool xhas_in ();
 
49
 
 
50
    private:
 
51
 
 
52
        //  Hook into the termination process.
 
53
        void process_term (int linger_);
 
54
 
 
55
        //  Check whether the message matches at least one subscription.
 
56
        bool match (zmq_msg_t *msg_);
 
57
 
 
58
        //  Fair queueing object for inbound pipes.
 
59
        fq_t fq;
 
60
 
 
61
        //  The repository of subscriptions.
 
62
        trie_t subscriptions;
 
63
 
 
64
        //  If true, 'message' contains a matching message to return on the
 
65
        //  next recv call.
 
66
        bool has_message;
 
67
        zmq_msg_t message;
 
68
 
 
69
        //  If true, part of a multipart message was already received, but
 
70
        //  there are following parts still waiting.
 
71
        bool more;
 
72
 
 
73
        xsub_t (const xsub_t&);
 
74
        const xsub_t &operator = (const xsub_t&);
 
75
    };
 
76
 
 
77
}
 
78
 
 
79
#endif
 
80