MongoDB C++ Driver mongocxx-3.11.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 <vector>
18
20
22
25
27
28namespace mongocxx {
29namespace v_noabi {
30namespace events {
31
32using mongocxx::v_noabi::read_preference; // Deprecated. Deliberately undocumented.
33
39 public:
44 private:
45 using container = std::vector<server_description>;
46
47 public:
52
57
59 server_descriptions& operator=(const server_descriptions&) = delete;
60
65
69 using iterator = container::iterator;
70
74 using const_iterator = container::const_iterator;
75
84
93
97 MONGOCXX_ABI_EXPORT_CDECL(std::size_t) size() const noexcept;
98
99 private:
100 friend ::mongocxx::v_noabi::events::topology_description;
101
102 explicit server_descriptions(void* sds, std::size_t size);
103 void swap(server_descriptions& other) noexcept;
104
105 container _container;
106 void* _sds;
107 std::size_t _size;
108 };
109
110 explicit topology_description(void* event);
111
116
118 topology_description& operator=(topology_description&&) = default;
119
121 topology_description& operator=(const topology_description&) = default;
122
129 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::string_view) type() const;
130
141 has_readable_server(const mongocxx::v_noabi::read_preference& pref) const;
142
152
159
160 private:
161 // Non-const since mongoc_topology_description_has_readable_server/writable_server take
162 // non-const. They do server selection, which modifies the mongoc_topology_description_t.
163 void* _td;
164};
165
166} // namespace events
167} // namespace v_noabi
168} // namespace mongocxx
169
170namespace mongocxx {
171namespace events {
172
173using ::mongocxx::v_noabi::events::read_preference; // Deprecated. Deliberately undocumented.
174
175} // namespace events
176} // namespace mongocxx
177
179
An array of server_description instances.
Definition topology_description.hpp:43
iterator end() noexcept
Returns an iterator to the end.
iterator begin() noexcept
Returns an iterator to the beginning.
container::iterator iterator
The array's iterator type.
Definition topology_description.hpp:69
container::const_iterator const_iterator
The array's const iterator type.
Definition topology_description.hpp:74
std::size_t size() const noexcept
The number of server_description instances in the array.
Class representing what the driver knows about a topology of MongoDB servers: either a standalone,...
Definition topology_description.hpp:38
bool has_readable_server(const mongocxx::v_noabi::read_preference &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,...
bsoncxx::v_noabi::stdx::string_view type() const
The topology type: "Unknown", "Sharded", "ReplicaSetNoPrimary", "ReplicaSetWithPrimary",...
server_descriptions servers() const
Fetches descriptions for all known servers in the topology.
Class representing a preference for how the driver routes read operations to members of a replica set...
Definition read_preference.hpp:65
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition fwd.hpp:222
The mongocxx macro guard postlude header.
The mongocxx macro guard prelude header.
The top-level namespace within which all bsoncxx library entities are declared.
The top-level namespace within which all mongocxx library entities are declared.
The top-level namespace reserved for the C++ standard library.
Provides mongocxx::v_noabi::read_preference.
Provides mongocxx::v_noabi::events::server_description.
Provides std::string_view-related polyfills for library API usage.
Declares mongocxx::v_noabi::events::topology_description.