| 1 |
#ifndef PROTON_LINK_HPP |
| 2 |
#define PROTON_LINK_HPP |
| 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 "./fwd.hpp" |
| 26 |
#include "./internal/export.hpp" |
| 27 |
#include "./endpoint.hpp" |
| 28 |
#include "./internal/object.hpp" |
| 29 |
|
| 30 |
#include <map> |
| 31 |
#include <string> |
| 32 |
|
| 33 |
/// @file |
| 34 |
/// @copybrief proton::link |
| 35 |
|
| 36 |
struct pn_link_t; |
| 37 |
|
| 38 |
namespace proton { |
| 39 |
|
| 40 |
/// A named channel for sending or receiving messages. It is the base |
| 41 |
/// class for sender and receiver. |
| 42 |
class |
| 43 |
PN_CPP_CLASS_EXTERN link : public internal::object<pn_link_t> , public endpoint { |
| 44 |
/// @cond INTERNAL |
| 45 |
link(pn_link_t* l) : internal::object<pn_link_t>(l) {} |
| 46 |
/// @endcond |
| 47 |
|
| 48 |
public: |
| 49 |
/// Create an empty link. |
| 50 |
link() : internal::object<pn_link_t>(0) {} |
| 51 |
|
| 52 |
PN_CPP_EXTERN bool uninitialized() const; |
| 53 |
PN_CPP_EXTERN bool active() const; |
| 54 |
PN_CPP_EXTERN bool closed() const; |
| 55 |
|
| 56 |
PN_CPP_EXTERN class error_condition error() const; |
| 57 |
|
| 58 |
PN_CPP_EXTERN void close(); |
| 59 |
PN_CPP_EXTERN void close(const error_condition&); |
| 60 |
|
| 61 |
/// Suspend the link without closing it. A suspended link may be |
| 62 |
/// reopened with the same or different link options if supported |
| 63 |
/// by the peer. A suspended durable subscription becomes inactive |
| 64 |
/// without cancelling it. |
| 65 |
// XXX Should take error condition |
| 66 |
PN_CPP_EXTERN void detach(); |
| 67 |
|
| 68 |
/// Credit available on the link. |
| 69 |
PN_CPP_EXTERN int credit() const; |
| 70 |
|
| 71 |
/// **Unsettled API** - True for a receiver if a drain cycle has |
| 72 |
/// been started and the corresponding `on_receiver_drain_finish` |
| 73 |
/// event is still pending. True for a sender if the receiver has |
| 74 |
/// requested a drain of credit and the sender has unused credit. |
| 75 |
/// |
| 76 |
/// @see @ref receiver::drain. |
| 77 |
PN_CPP_EXTERN bool draining(); |
| 78 |
|
| 79 |
/// Get the link name. |
| 80 |
PN_CPP_EXTERN std::string name() const; |
| 81 |
|
| 82 |
/// The container for this link. |
| 83 |
PN_CPP_EXTERN class container &container() const; |
| 84 |
|
| 85 |
/// Get the work_queue for the link. |
| 86 |
PN_CPP_EXTERN class work_queue& work_queue() const; |
| 87 |
|
| 88 |
/// The connection that owns this link. |
| 89 |
PN_CPP_EXTERN class connection connection() const; |
| 90 |
|
| 91 |
/// The session that owns this link. |
| 92 |
PN_CPP_EXTERN class session session() const; |
| 93 |
|
| 94 |
/// **Unsettled API** - Properties supplied by the remote link endpoint. |
| 95 |
PN_CPP_EXTERN std::map<symbol, value> properties() const; |
| 96 |
|
| 97 |
protected: |
| 98 |
/// @cond INTERNAL |
| 99 |
|
| 100 |
// Initiate the AMQP attach frame. |
| 101 |
void attach(); |
| 102 |
|
| 103 |
friend class internal::factory<link>; |
| 104 |
|
| 105 |
/// @endcond |
| 106 |
}; |
| 107 |
|
| 108 |
} |
| 109 |
|
| 110 |
#endif // PROTON_LINK_HPP |