pair.hpp 2.13 KB
Newer Older
1
/*
2 3
    Copyright (c) 2007-2011 iMatix Corporation
    Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
4 5 6 7

    This file is part of 0MQ.

    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 10 11 12 13 14
    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
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 19 20
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

Martin Sustrik's avatar
Martin Sustrik committed
21 22
#ifndef __ZMQ_PAIR_HPP_INCLUDED__
#define __ZMQ_PAIR_HPP_INCLUDED__
23 24

#include "socket_base.hpp"
25
#include "pipe.hpp"
26 27 28 29

namespace zmq
{

30 31 32 33
    class pair_t :
        public socket_base_t,
        public i_reader_events,
        public i_writer_events
34 35 36
    {
    public:

Martin Sustrik's avatar
Martin Sustrik committed
37
        pair_t (class ctx_t *parent_, uint32_t tid_);
Martin Sustrik's avatar
Martin Sustrik committed
38
        ~pair_t ();
39 40

        //  Overloads of functions from socket_base_t.
41 42
        void xattach_pipes (class reader_t *inpipe_, class writer_t *outpipe_,
            const blob_t &peer_identity_);
43 44
        int xsend (zmq_msg_t *msg_, int flags_);
        int xrecv (zmq_msg_t *msg_, int flags_);
45 46
        bool xhas_in ();
        bool xhas_out ();
47

48 49 50
        //  i_reader_events interface implementation.
        void activated (class reader_t *pipe_);
        void terminated (class reader_t *pipe_);
51
        void delimited (class reader_t *pipe_);
52 53 54 55 56

        //  i_writer_events interface implementation.
        void activated (class writer_t *pipe_);
        void terminated (class writer_t *pipe_);

57 58
    private:

59
        //  Hook into termination process.
60
        void process_term (int linger_);
61

62 63 64
        class reader_t *inpipe;
        class writer_t *outpipe;

65
        bool inpipe_alive;
66
        bool outpipe_alive;
67

68 69
        bool terminating;

Martin Sustrik's avatar
Martin Sustrik committed
70
        pair_t (const pair_t&);
71
        const pair_t &operator = (const pair_t&);
72 73 74 75 76
    };

}

#endif