| 1 |
#ifndef PROTON_SENDER_HPP |
| 2 |
#define PROTON_SENDER_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 "./link.hpp" |
| 28 |
#include "./tracker.hpp" |
| 29 |
|
| 30 |
/// @file |
| 31 |
/// @copybrief proton::sender |
| 32 |
|
| 33 |
struct pn_link_t; |
| 34 |
struct pn_session_t; |
| 35 |
|
| 36 |
namespace proton { |
| 37 |
|
| 38 |
/// A channel for sending messages. |
| 39 |
class |
| 40 |
PN_CPP_CLASS_EXTERN sender : public link { |
| 41 |
/// @cond INTERNAL |
| 42 |
PN_CPP_EXTERN sender(pn_link_t* s); |
| 43 |
/// @endcond |
| 44 |
|
| 45 |
public: |
| 46 |
/// Create an empty sender. |
| 47 |
sender() = default; |
| 48 |
|
| 49 |
PN_CPP_EXTERN ~sender(); |
| 50 |
|
| 51 |
/// Open the sender. |
| 52 |
PN_CPP_EXTERN void open(); |
| 53 |
|
| 54 |
/// @copydoc open |
| 55 |
PN_CPP_EXTERN void open(const sender_options &opts); |
| 56 |
|
| 57 |
/// Send a message on the sender. |
| 58 |
PN_CPP_EXTERN tracker send(const message &m); |
| 59 |
PN_CPP_EXTERN tracker send(const message &m, const binary &tag); |
| 60 |
|
| 61 |
/// Get the source node. |
| 62 |
PN_CPP_EXTERN class source source() const; |
| 63 |
|
| 64 |
/// Get the target node. |
| 65 |
PN_CPP_EXTERN class target target() const; |
| 66 |
|
| 67 |
/// **Unsettled API** - Return all unused credit to the receiver in |
| 68 |
/// response to a drain request. Has no effect unless there has |
| 69 |
/// been a drain request and there is remaining credit to use or |
| 70 |
/// return. |
| 71 |
/// |
| 72 |
/// @see receiver::drain |
| 73 |
PN_CPP_EXTERN void return_credit(); |
| 74 |
|
| 75 |
/// @cond INTERNAL |
| 76 |
friend class internal::factory<sender>; |
| 77 |
friend class sender_iterator; |
| 78 |
/// @endcond |
| 79 |
|
| 80 |
private: |
| 81 |
/// @cond INTERNAL |
| 82 |
uint64_t tag_counter = 0; |
| 83 |
/// @endcond |
| 84 |
}; |
| 85 |
|
| 86 |
/// @cond INTERNAL |
| 87 |
|
| 88 |
/// An iterator of senders. |
| 89 |
class sender_iterator : public internal::iter_base<sender, sender_iterator> { |
| 90 |
sender_iterator(sender snd, pn_session_t* s = 0) : |
| 91 |
internal::iter_base<sender, sender_iterator>(snd), session_(s) {} |
| 92 |
|
| 93 |
public: |
| 94 |
/// Create an iterator of senders. |
| 95 |
sender_iterator() : |
| 96 |
internal::iter_base<sender, sender_iterator>(0), session_(0) {} |
| 97 |
/// Advance to the next sender. |
| 98 |
PN_CPP_EXTERN sender_iterator operator++(); |
| 99 |
|
| 100 |
private: |
| 101 |
pn_session_t* session_; |
| 102 |
|
| 103 |
friend class connection; |
| 104 |
friend class session; |
| 105 |
}; |
| 106 |
|
| 107 |
/// A range of senders. |
| 108 |
typedef internal::iter_range<sender_iterator> sender_range; |
| 109 |
|
| 110 |
/// @endcond |
| 111 |
|
| 112 |
} |
| 113 |
|
| 114 |
#endif // PROTON_SENDER_HPP |