RMQ - RabbitMQ C++ Library
rmqt_exchange.h
1// Copyright 2020-2023 Bloomberg Finance L.P.
2// SPDX-License-Identifier: Apache-2.0
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16#ifndef INCLUDED_RMQT_EXCHANGE
17#define INCLUDED_RMQT_EXCHANGE
18
19#include <rmqt_exchangetype.h>
20#include <rmqt_fieldvalue.h>
21
22#include <bsl_memory.h>
23#include <bsl_ostream.h>
24#include <bsl_string.h>
25
26//@PURPOSE: Provide an AMQP exchange.
27//
28//@CLASSES:
29// rmqt::exchange: a RabbitMQ Exchange API object
30
31namespace BloombergLP {
32namespace rmqt {
33
39class Exchange {
40 public:
41 static const char DEFAULT_EXCHANGE[];
42 // CREATORS
47 explicit Exchange(
48 const bsl::string& name,
49 bool passive = false,
50 const rmqt::ExchangeType& exchangeType = ExchangeType::DIRECT,
51 bool autoDelete = false,
52 bool durable = true,
53 bool internal = false,
54 const rmqt::FieldTable& args = rmqt::FieldTable());
55
56 bool passive() const;
57 const bsl::string& name() const;
58 const bsl::string& type() const;
59 bool autoDelete() const;
60 bool durable() const;
61 bool internal() const;
62 const rmqt::FieldTable& arguments() const;
63
72 bool isDefault() const;
73
74 friend bsl::ostream& operator<<(bsl::ostream& os, const Exchange& exchange);
75
76 private:
77 const bsl::string d_name;
78 const bsl::string d_exchangeType;
79 const bool d_passive;
80 const bool d_autoDelete;
81 const bool d_durable;
82 const bool d_internal;
83 const rmqt::FieldTable d_args;
84};
85
87class ExchangeUtil {
88 public:
90 static bool validateName(const bsl::string& exchangeName);
91};
92
93typedef bsl::weak_ptr<Exchange> ExchangeHandle;
94
95bool operator==(const Exchange& lhs, const Exchange& rhs);
96bool operator!=(const Exchange& lhs, const Exchange& rhs);
97bsl::ostream& operator<<(bsl::ostream& os, const Exchange& exchange);
98
99} // namespace rmqt
100} // namespace BloombergLP
101
102#endif // ! INCLUDED_RMQT_EXCHANGE
AMQP Exchange types.
Definition: rmqt_exchangetype.h:27
An AMQP Exchange.
Definition: rmqt_exchange.h:39
Exchange(const bsl::string &name, bool passive=false, const rmqt::ExchangeType &exchangeType=ExchangeType::DIRECT, bool autoDelete=false, bool durable=true, bool internal=false, const rmqt::FieldTable &args=rmqt::FieldTable())
Definition: rmqt_exchange.cpp:32
bool isDefault() const
Definition: rmqt_exchange.cpp:64
Represents AMQP 0.9.1 Field Table (dict of FieldValues)
Definition: rmqt_fieldvalue.h:108