MongoDB C++ Driver  mongocxx-3.10.2
transaction.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 <chrono>
18 #include <memory>
19 
20 #include <mongocxx/client_session-fwd.hpp>
21 #include <mongocxx/options/transaction-fwd.hpp>
22 #include <mongocxx/read_concern-fwd.hpp>
23 #include <mongocxx/read_preference-fwd.hpp>
24 #include <mongocxx/write_concern-fwd.hpp>
25 
26 #include <bsoncxx/stdx/optional.hpp>
27 #include <mongocxx/stdx.hpp>
28 
29 #include <mongocxx/config/prelude.hpp>
30 
31 namespace mongocxx {
32 namespace v_noabi {
33 namespace options {
34 
38 class transaction {
39  public:
40  transaction();
41 
46 
51 
55  transaction(transaction&&) noexcept;
56 
60  transaction& operator=(transaction&&) noexcept;
61 
65  ~transaction() noexcept;
66 
78 
85  stdx::optional<mongocxx::v_noabi::read_concern> read_concern() const;
86 
98 
107  stdx::optional<mongocxx::v_noabi::write_concern> write_concern() const;
108 
120 
127  stdx::optional<mongocxx::v_noabi::read_preference> read_preference() const;
128 
138  transaction& max_commit_time_ms(std::chrono::milliseconds ms);
139 
147  stdx::optional<std::chrono::milliseconds> max_commit_time_ms() const;
148 
149  private:
150  friend ::mongocxx::v_noabi::client_session;
151 
152  class MONGOCXX_PRIVATE impl;
153 
154  MONGOCXX_PRIVATE impl& _get_impl();
155  MONGOCXX_PRIVATE const impl& _get_impl() const;
156  std::unique_ptr<impl> _impl;
157 };
158 
159 } // namespace options
160 } // namespace v_noabi
161 } // namespace mongocxx
162 
163 #include <mongocxx/config/postlude.hpp>
Class representing the optional arguments to mongocxx::v_noabi::client::start_session.
Definition: client_session.hpp:33
Class representing the optional arguments for a transaction.
Definition: transaction.hpp:38
transaction & operator=(const transaction &)
Copy assigns transaction options.
stdx::optional< std::chrono::milliseconds > max_commit_time_ms() const
Gets the current transaction commit time, in milliseconds.
transaction(transaction &&) noexcept
Move constructs transaction options.
transaction(const transaction &)
Copy constructs transaction options.
A class to represent the read concern.
Definition: read_concern.hpp:56
Class representing a preference for how the driver routes read operations to members of a replica set...
Definition: read_preference.hpp:63
Class representing the server-side requirement for reporting the success of a write operation.
Definition: write_concern.hpp:58
The top-level namespace for mongocxx library entities.
Definition: bulk_write-fwd.hpp:19