MongoDB C++ Driver  mongocxx-3.3.2
All Classes Namespaces Functions Enumerations Enumerator Friends Pages
client_session.hpp
1 // Copyright 2017-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 <memory>
18 
19 #include <bsoncxx/document/view.hpp>
20 #include <bsoncxx/stdx/optional.hpp>
21 #include <mongocxx/options/client_session.hpp>
22 
23 #include <mongocxx/config/prelude.hpp>
24 
25 namespace mongocxx {
26 MONGOCXX_INLINE_NAMESPACE_BEGIN
27 
28 class client;
29 
38 class MONGOCXX_API client_session {
39  public:
43  client_session(client_session&&) noexcept;
44 
48  client_session& operator=(client_session&&) noexcept;
49 
50  client_session(const client_session&) = delete;
51  client_session& operator=(const client_session&) = delete;
52 
56  ~client_session() noexcept;
57 
61  const class client& client() const noexcept;
62 
66  const options::client_session& options() const noexcept;
67 
72  bsoncxx::document::view id() const noexcept;
73 
80  bsoncxx::document::view cluster_time() const noexcept;
81 
87  bsoncxx::types::b_timestamp operation_time() const noexcept;
88 
97  void advance_cluster_time(const bsoncxx::document::view& cluster_time);
98 
107  void advance_operation_time(const bsoncxx::types::b_timestamp& operation_time);
108 
109  private:
110  friend class bulk_write;
111  friend class client;
112  friend class collection;
113  friend class database;
114  friend class index_view;
115 
116  class MONGOCXX_PRIVATE impl;
117 
118  // "class client" distinguishes from client() method above.
119  MONGOCXX_PRIVATE client_session(const class client* client,
120  const options::client_session& options);
121 
122  MONGOCXX_PRIVATE impl& _get_impl();
123  MONGOCXX_PRIVATE const impl& _get_impl() const;
124 
125  std::unique_ptr<impl> _impl;
126 };
127 
128 MONGOCXX_INLINE_NAMESPACE_END
129 } // namespace mongocxx
130 
131 #include <mongocxx/config/postlude.hpp>
132 
Top level namespace for the MongoDB C++ driver.
Definition: bulk_write.hpp:24
A read-only, non-owning view of a BSON document.
Definition: view.hpp:33
Class representing a client connection to MongoDB.
Definition: client.hpp:57
Use a session for a sequence of operations, optionally with causal consistency.
Definition: client_session.hpp:38
Class representing a MongoDB database.
Definition: database.hpp:47
Class representing a batch of write operations that can be sent to the server as a group...
Definition: bulk_write.hpp:43
A BSON replication timestamp value.
Definition: types.hpp:558
Class representing the optional arguments to mongocxx::client::start_session.
Definition: client_session.hpp:26
Definition: index_view.hpp:32
Class representing server side document groupings within a MongoDB database.
Definition: collection.hpp:87