MongoDB C++ Driver 4.2.0
Loading...
Searching...
No Matches
topology_description.hpp
Go to the documentation of this file.
1// Copyright 2009-present MongoDB, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <mongocxx/events/topology_description-fwd.hpp> // IWYU pragma: export
18
19//
20
21#include <mongocxx/v1/events/topology_description.hpp> // IWYU pragma: export
22
23#include <cstddef>
24#include <vector>
25
27
30
32
33namespace mongocxx {
34namespace v_noabi {
35namespace events {
36
43class topology_description {
44 private:
46
47 public:
52 private:
53 using container = std::vector<server_description>;
54
55 public:
60
65
67 server_descriptions& operator=(server_descriptions const&) = delete;
68
73
77 using iterator = container::iterator;
78
82 using const_iterator = container::const_iterator;
83
88 iterator begin() noexcept {
89 return _container.begin();
90 }
91 const_iterator begin() const noexcept {
92 return _container.begin();
93 }
94
96
101 iterator end() noexcept {
102 return _container.end();
103 }
104 const_iterator end() const noexcept {
105 return _container.begin();
106 }
107
109
113 std::size_t size() const noexcept {
114 return _container.size();
115 }
116
117 private:
118 friend topology_description;
119
120 server_descriptions(void* sds, std::size_t size);
121
122 container _container;
123 void* _sds;
124 std::size_t _size;
125 };
126
127 explicit MONGOCXX_ABI_EXPORT_CDECL() topology_description(void const* td);
128
132 /* explicit(false) */ topology_description(v1::events::topology_description const& td) : _td{td} {}
133
137 explicit operator v1::events::topology_description() const {
138 return _td;
139 }
140
148 return _td.type();
149 }
150
161
170 bool has_writable_server() const {
171 return _td.has_writable_server();
172 }
173
180};
181
182} // namespace events
183} // namespace v_noabi
184} // namespace mongocxx
185
186namespace mongocxx {
187namespace v_noabi {
188
195
202
203} // namespace v_noabi
204} // namespace mongocxx
205
207
A polyfill for std::string_view.
Definition string_view.hpp:412
server_descriptions(server_descriptions &&) noexcept
Move constructs a server_descriptions array.
TopologyDescription from the SDAM Logging and Monitoring specification.
Definition topology_description.hpp:44
An array of server_description instances.
Definition topology_description.hpp:51
iterator end() noexcept
Returns an iterator to the end.
Definition topology_description.hpp:101
iterator begin() noexcept
Returns an iterator to the beginning.
Definition topology_description.hpp:88
const_iterator end() const noexcept
Returns an iterator to the end.
Definition topology_description.hpp:104
server_descriptions(server_descriptions &&) noexcept
Move constructs a server_descriptions array.
container::iterator iterator
The array's iterator type.
Definition topology_description.hpp:77
container::const_iterator const_iterator
The array's const iterator type.
Definition topology_description.hpp:82
const_iterator begin() const noexcept
Returns an iterator to the beginning.
Definition topology_description.hpp:91
std::size_t size() const noexcept
The number of server_description instances in the array.
Definition topology_description.hpp:113
A description of the topology of one or more connected MongoDB servers.
Definition topology_description.hpp:43
bool has_readable_server(v_noabi::read_preference const &pref) const
Determines if the topology has a readable server available. Servers are filtered by the given read pr...
bool has_writable_server() const
Determines if the topology has a writable server available, such as a primary, mongos,...
Definition topology_description.hpp:170
bsoncxx::v_noabi::stdx::string_view type() const
The topology type: "Unknown", "Sharded", "ReplicaSetNoPrimary", "ReplicaSetWithPrimary",...
Definition topology_description.hpp:147
server_descriptions servers() const
Fetches descriptions for all known servers in the topology.
Describes how MongoDB clients route read operations to the members of a replica set or sharded cluste...
Definition read_preference.hpp:59
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
The mongocxx v_noabi macro guard postlude header.
The mongocxx v_noabi macro guard prelude header.
Declares entities whose ABI stability is guaranteed for documented symbols.
Declares entities describing APM events.
Declares entities whose ABI stability is NOT guaranteed.
v1::bulk_write to_v1(v_noabi::bulk_write v)
Convert to the mongocxx::v1 equivalent of v.
Definition bulk_write.hpp:162
v_noabi::bulk_write from_v1(v1::bulk_write v)
Convert to the mongocxx::v_noabi equivalent of v.
Definition bulk_write.hpp:155
The top-level namespace within which all mongocxx library entities are declared.
Provides mongocxx::v1::events::topology_description.
Provides std::string_view-related polyfills for library API usage.
Provides mongocxx::v_noabi::events::server_description.
Declares mongocxx::v_noabi::events::topology_description.
Provides mongocxx::v_noabi::read_preference.