MongoDB C++ Driver current
Loading...
Searching...
No Matches
topology_description.hpp
1// Copyright 2018-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
19#include <bsoncxx/stdx/string_view.hpp>
20#include <mongocxx/events/server_description.hpp>
21#include <mongocxx/read_preference.hpp>
22
23#include <mongocxx/config/prelude.hpp>
24
25namespace mongocxx {
26inline namespace v_noabi {
27namespace events {
28
30
35class MONGOCXX_API topology_description {
36 public:
40 class MONGOCXX_API server_descriptions {
41 private:
42 using container = std::vector<server_description>;
43
44 public:
49
54
56 server_descriptions& operator=(const server_descriptions&) = delete;
57
62
66 using iterator = container::iterator;
67
71 using const_iterator = container::const_iterator;
72
78 iterator begin() noexcept;
79 const_iterator begin() const noexcept;
80
84
90 iterator end() noexcept;
91 const_iterator end() const noexcept;
92
96
100 std::size_t size() const noexcept;
101
102 private:
104 MONGOCXX_PRIVATE explicit server_descriptions(void* sds, std::size_t size);
105 MONGOCXX_PRIVATE void swap(server_descriptions& other) noexcept;
106 container _container;
107 void* _sds;
108 std::size_t _size;
109 };
110
111 MONGOCXX_PRIVATE explicit topology_description(void* event);
112
117
124 bsoncxx::stdx::string_view type() const;
125
135 bool has_readable_server(const mongocxx::read_preference& pref) const;
136
145 bool has_writable_server() const;
146
152 server_descriptions servers() const;
153
154 private:
155 // Non-const since mongoc_topology_description_has_readable_server/writable_server take
156 // non-const. They do server selection, which modifies the mongoc_topology_description_t.
157 void* _td;
158};
159
160} // namespace events
161} // namespace v_noabi
162} // namespace mongocxx
163
164#include <mongocxx/config/postlude.hpp>
An array of server_description instances.
Definition topology_description.hpp:40
server_descriptions(server_descriptions &&) noexcept
Move constructs a server_descriptions array.
container::iterator iterator
The array's iterator type.
Definition topology_description.hpp:66
container::const_iterator const_iterator
The array's const iterator type.
Definition topology_description.hpp:71
Class representing what the driver knows about a topology of MongoDB servers: either a standalone,...
Definition topology_description.hpp:35
Class representing a preference for how the driver routes read operations to members of a replica set...
Definition read_preference.hpp:67
The top-level namespace for bsoncxx library entities.
Definition element.hpp:24
The top-level namespace for mongocxx library entities.
Definition bulk_write.hpp:24