Qpid Proton C++  0.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
link.hpp
1 #ifndef PROTON_CPP_LINK_H
2 #define PROTON_CPP_LINK_H
3 
4 /*
5  *
6  * Licensed to the Apache Software Foundation (ASF) under one
7  * or more contributor license agreements. See the NOTICE file
8  * distributed with this work for additional information
9  * regarding copyright ownership. The ASF licenses this file
10  * to you under the Apache License, Version 2.0 (the
11  * "License"); you may not use this file except in compliance
12  * with the License. You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing,
17  * software distributed under the License is distributed on an
18  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19  * KIND, either express or implied. See the License for the
20  * specific language governing permissions and limitations
21  * under the License.
22  *
23  */
24 
25 #include "proton/endpoint.hpp"
26 #include "proton/export.hpp"
27 #include "proton/message.hpp"
28 #include "proton/terminus.hpp"
29 #include "proton/types.h"
30 #include "proton/object.hpp"
31 #include "proton/link_options.hpp"
32 
33 #include <string>
34 
35 namespace proton {
36 
37 class sender;
38 class receiver;
39 class condition;
40 
43 class link : public object<pn_link_t> , public endpoint {
44  public:
46  link(pn_link_t* l=0) : object<pn_link_t>(l) {}
48 
49  // Endpoint behaviours
50 
52  PN_CPP_EXTERN endpoint::state state() const;
53 
54  PN_CPP_EXTERN condition local_condition() const;
55  PN_CPP_EXTERN condition remote_condition() const;
56 
59  PN_CPP_EXTERN void open(const link_options &opts = link_options());
60 
63  PN_CPP_EXTERN void close();
64 
66  PN_CPP_EXTERN class sender sender();
67 
69  PN_CPP_EXTERN const class sender sender() const;
70 
72  PN_CPP_EXTERN class receiver receiver();
73 
75  PN_CPP_EXTERN const class receiver receiver() const;
76 
78  PN_CPP_EXTERN int credit() const;
79 
81  PN_CPP_EXTERN int queued();
82 
86  PN_CPP_EXTERN int unsettled();
88 
91  PN_CPP_EXTERN int drained();
93 
95  PN_CPP_EXTERN terminus local_source() const;
96 
98  PN_CPP_EXTERN terminus local_target() const;
99 
101  PN_CPP_EXTERN terminus remote_source() const;
102 
104  PN_CPP_EXTERN terminus remote_target() const;
105 
107  PN_CPP_EXTERN std::string name() const;
108 
110  PN_CPP_EXTERN class connection connection() const;
111 
113  PN_CPP_EXTERN class session session() const;
114 
117 
119  PN_CPP_EXTERN void handler(proton_handler &);
120 
122  PN_CPP_EXTERN void detach_handler();
123 
125 
128  PN_CPP_EXTERN ssize_t recv(char* buffer, size_t size);
129 
132  PN_CPP_EXTERN bool advance();
133 
136  PN_CPP_EXTERN link next(endpoint::state) const;
137 
139  PN_CPP_EXTERN link_options::sender_settle_mode sender_settle_mode();
140  PN_CPP_EXTERN void sender_settle_mode(link_options::sender_settle_mode);
141  PN_CPP_EXTERN link_options::receiver_settle_mode receiver_settle_mode();
142  PN_CPP_EXTERN void receiver_settle_mode(link_options::receiver_settle_mode);
143  PN_CPP_EXTERN link_options::sender_settle_mode remote_sender_settle_mode();
144  PN_CPP_EXTERN link_options::receiver_settle_mode remote_receiver_settle_mode();
145 
147 };
148 
152 class link_iterator : public iter_base<link> {
153  public:
154  explicit link_iterator(link p = 0, endpoint::state s = 0) :
155  iter_base<link>(p, s), session_(0) {}
156  explicit link_iterator(const link_iterator& i, const session& ssn) :
157  iter_base<link>(i.ptr_, i.state_), session_(&ssn) {}
158  PN_CPP_EXTERN link_iterator operator++();
159  link_iterator operator++(int) { link_iterator x(*this); ++(*this); return x; }
160 
161  private:
162  const session* session_;
163 };
165 
167 typedef range<link_iterator> link_range;
168 
169 }
170 
171 #include "proton/sender.hpp"
172 #include "proton/receiver.hpp"
173 
174 #endif // PROTON_CPP_LINK_H
One end of a link, either a source or a target.
Definition: terminus.hpp:42
A link for sending messages.
Definition: sender.hpp:38
A connection to a remote AMQP peer.
Definition: connection.hpp:42
The base class for session, connection, and link.
Definition: endpoint.hpp:32
A container of links.
Definition: session.hpp:42
Describes an endpoint error state.
Definition: condition.hpp:35
int state
A bit mask of state bit values.
Definition: endpoint.hpp:45
Callback functions for handling proton events.
Definition: handler.hpp:40
A link for receiving messages.
Definition: receiver.hpp:36