MongoDB C++ Driver mongocxx-4.0.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
37 public:
42 private:
43 using container = std::vector<server_description>;
44
45 public:
50
55
57 server_descriptions& operator=(const server_descriptions&) = delete;
58
63
67 using iterator = container::iterator;
68
72 using const_iterator = container::const_iterator;
73
82
91
95 MONGOCXX_ABI_EXPORT_CDECL(std::size_t) size() const noexcept;
96
97 private:
98 friend ::mongocxx::v_noabi::events::topology_description;
99
100 explicit server_descriptions(void* sds, std::size_t size);
101 void swap(server_descriptions& other) noexcept;
102
103 container _container;
104 void* _sds;
105 std::size_t _size;
106 };
107
108 explicit topology_description(void* event);
109
114
116 topology_description& operator=(topology_description&&) = default;
117
119 topology_description& operator=(const topology_description&) = default;
120
127 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::string_view) type() const;
128
139 has_readable_server(const mongocxx::v_noabi::read_preference& pref) const;
140
150
157
158 private:
159 // Non-const since mongoc_topology_description_has_readable_server/writable_server take
160 // non-const. They do server selection, which modifies the mongoc_topology_description_t.
161 void* _td;
162};
163
164} // namespace events
165} // namespace v_noabi
166} // namespace mongocxx
167
168#include <mongocxx/config/postlude.hpp>
169
An array of server_description instances.
Definition topology_description.hpp:41
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:67
container::const_iterator const_iterator
The array's const iterator type.
Definition topology_description.hpp:72
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:36
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:64
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition fwd.hpp:204
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.