Debian Codegraph @

cpp/include/proton/receiver_options.hpp

raw
1 #ifndef PROTON_RECEIVER_OPTIONS_HPP
2 #define PROTON_RECEIVER_OPTIONS_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 "./delivery_mode.hpp"
28 #include "./types_fwd.hpp"
29
30 #include <map>
31 #include <memory>
32 #include <string>
33
34 /// @file
35 /// @copybrief proton::receiver_options
36
37 namespace proton {
38
39 /// Options for creating a receiver.
40 ///
41 /// Options can be "chained" like this:
42 ///
43 /// @code
44 /// l = container.create_receiver(url, receiver_options().handler(h).auto_accept(true));
45 /// @endcode
46 ///
47 /// You can also create an options object with common settings and use
48 /// it as a base for different connections that have mostly the same
49 /// settings:
50 ///
51 /// @code
52 /// receiver_options opts;
53 /// opts.auto_accept(true);
54 /// c2 = container.open_receiver(url2, opts.handler(h2));
55 /// @endcode
56 ///
57 /// Normal value semantics: copy or assign creates a separate copy of
58 /// the options.
59 class receiver_options {
60 public:
61 /// Create an empty set of options.
62 PN_CPP_EXTERN receiver_options();
63
64 /// Copy options.
65 PN_CPP_EXTERN receiver_options(const receiver_options&);
66
67 PN_CPP_EXTERN ~receiver_options();
68
69 /// Copy options.
70 PN_CPP_EXTERN receiver_options& operator=(const receiver_options&);
71
72 /// Merge with another option set.
73 PN_CPP_EXTERN void update(const receiver_options& other);
74
75 /// Set a messaging_handler for receiver events only. The handler
76 /// is no longer in use when
77 /// messaging_handler::on_receiver_close() is called.
78 PN_CPP_EXTERN receiver_options& handler(class messaging_handler&);
79
80 /// Set the delivery mode on the receiver. The default is
81 /// delivery_mode::AT_LEAST_ONCE.
82 PN_CPP_EXTERN receiver_options& delivery_mode(delivery_mode);
83
84 /// Enable or disable automatic acceptance of messages that aren't
85 /// otherwise released, rejected, or modified. It is enabled by
86 /// default.
87 PN_CPP_EXTERN receiver_options& auto_accept(bool);
88
89 /// **Deprecated** - Applicable only to sender, not receiver.
90 PN_CPP_EXTERN PN_CPP_DEPRECATED("applicable only to sender, not receiver") receiver_options& auto_settle(bool);
91
92 /// Options for the source node of the receiver.
93 PN_CPP_EXTERN receiver_options& source(source_options&);
94
95 /// Options for the target node of the receiver.
96 PN_CPP_EXTERN receiver_options& target(target_options&);
97
98 /// Automatically replenish credit for flow control up to `count`
99 /// messages. The default is 10. Set to zero to disable
100 /// automatic replenishment.
101 PN_CPP_EXTERN receiver_options& credit_window(int count);
102
103 /// Set the link name. If not set a unique name is generated.
104 PN_CPP_EXTERN receiver_options& name(const std::string& name);
105
106 /// **Unsettled API** - Link properties.
107 PN_CPP_EXTERN receiver_options& properties(const std::map<symbol, value>&);
108
109 private:
110 void apply(receiver &) const;
111 const std::string* get_name() const; // Pointer to name if set, else 0
112
113 class impl;
114 std::unique_ptr<impl> impl_;
115
116 /// @cond INTERNAL
117 friend class receiver;
118 friend class session;
119 /// @endcond
120 };
121
122 } // proton
123
124 #endif // PROTON_RECEIVER_OPTIONS_HPP