azure-core-amqp
Loading...
Searching...
No Matches
message_source.hpp
1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4#pragma once
5
6#include "azure/core/amqp/models/amqp_header.hpp"
7#include "azure/core/amqp/models/amqp_properties.hpp"
8#include "azure/core/amqp/models/amqp_value.hpp"
9
10#include <chrono>
11#include <string>
12
13struct SOURCE_INSTANCE_TAG;
14
15namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace _detail {
16 class MessageSourceImpl;
17}}}}} // namespace Azure::Core::Amqp::Models::_detail
18
19namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace _internal {
20
21 struct MessageSourceOptions final
22 {
23 AmqpValue Address;
24 Nullable<TerminusDurability> SourceTerminusDurability;
25 Nullable<TerminusExpiryPolicy> SourceTerminusExpiryPolicy;
26 Nullable<std::chrono::system_clock::time_point> Timeout;
27 Nullable<bool> Dynamic;
28 AmqpMap DynamicNodeProperties;
29 Nullable<std::string> DistributionMode;
30 AmqpMap Filter;
31 AmqpValue DefaultOutcome;
32 AmqpArray Outcomes;
33 AmqpArray Capabilities;
34 };
35
47 class MessageSource final {
48 public:
51 MessageSource();
53 ~MessageSource();
54
55 // Create a described source from an AMQP Value - used in the OnLinkAttached.
56 MessageSource(AmqpValue const& value);
57
59 MessageSource(MessageSource const& that);
60
63 MessageSource& operator=(MessageSource const& that);
64
66 MessageSource(MessageSource&& other) noexcept;
67
69 MessageSource& operator=(MessageSource&& other) noexcept;
70
76 MessageSource(MessageSourceOptions const& options);
77
78 /* Note: These constructors should NOT be marked as explicit, because we want to enable the
79 * implicit construction of the MessageSource from a string - this allows callers to construct
80 * Link, MessageSender, and MessageReceiver objects without forcing the creation of a
81 * MessageSource object. */
82
87 MessageSource(std::string const& address);
88
93 MessageSource(char const* address);
94
100 AmqpValue AsAmqpValue() const;
101
110 AmqpValue GetAddress() const;
111
120 TerminusDurability GetTerminusDurability() const;
121
130 TerminusExpiryPolicy GetExpiryPolicy() const;
131
142 std::chrono::system_clock::time_point GetTimeout() const;
143
152 bool GetDynamic() const;
153
163 AmqpMap GetDynamicNodeProperties() const;
164
173 std::string GetDistributionMode() const;
174
183 AmqpMap GetFilter() const;
184
194 AmqpValue GetDefaultOutcome() const;
195
205 AmqpArray GetOutcomes() const;
206
216 AmqpArray GetCapabilities() const;
217
218 private:
219 std::unique_ptr<_detail::MessageSourceImpl> m_impl;
220 // Declared as friend so it can access the private m_impl member.
221 friend std::ostream& operator<<(std::ostream&, MessageSource const&);
222 };
223}}}}} // namespace Azure::Core::Amqp::Models::_internal