rep.hpp 2.13 KB
Newer Older
1
/*
Martin Sustrik's avatar
Martin Sustrik committed
2
    Copyright (c) 2009-2011 250bpm s.r.o.
3 4
    Copyright (c) 2007-2011 iMatix Corporation
    Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
5 6 7 8

    This file is part of 0MQ.

    0MQ is free software; you can redistribute it and/or modify it under
9
    the terms of the GNU Lesser General Public License as published by
10 11 12 13 14 15
    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
16
    GNU Lesser General Public License for more details.
17

18
    You should have received a copy of the GNU Lesser General Public License
19 20 21
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

22 23
#ifndef __ZMQ_REP_HPP_INCLUDED__
#define __ZMQ_REP_HPP_INCLUDED__
24

25
#include "router.hpp"
26 27 28 29

namespace zmq
{

30 31 32 33 34
    class ctx_t;
    class msg_t;
    class io_thread_t;
    class socket_base_t;

35
    class rep_t : public router_t
36 37 38
    {
    public:

39
        rep_t (zmq::ctx_t *parent_, uint32_t tid_, int sid);
40 41 42
        ~rep_t ();

        //  Overloads of functions from socket_base_t.
43
        int xsend (zmq::msg_t *msg_);
44
        int xrecv (zmq::msg_t *msg_);
45 46
        bool xhas_in ();
        bool xhas_out ();
47 48 49

    private:

50 51
        //  If true, we are in process of sending the reply. If false we are
        //  in process of receiving a request.
52 53
        bool sending_reply;

54 55 56
        //  If true, we are starting to receive a request. The beginning
        //  of the request is the backtrace stack.
        bool request_begins;
57 58

        rep_t (const rep_t&);
59
        const rep_t &operator = (const rep_t&);
60 61 62

    };

63
    class rep_session_t : public router_session_t
64 65 66
    {
    public:

67 68
        rep_session_t (zmq::io_thread_t *io_thread_, bool connect_,
            zmq::socket_base_t *socket_, const options_t &options_,
69
            const address_t *addr_);
70 71 72 73 74 75 76 77
        ~rep_session_t ();

    private:

        rep_session_t (const rep_session_t&);
        const rep_session_t &operator = (const rep_session_t&);
    };

78 79 80
}

#endif