MongoDB C++ Driver  mongocxx-3.7.0
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 <bsoncxx/stdx/optional.hpp>
21 #include <mongocxx/stdx.hpp>
22 
23 #include <mongocxx/config/prelude.hpp>
24 
25 namespace mongocxx {
26 MONGOCXX_INLINE_NAMESPACE_BEGIN
27 
28 class client_session;
29 class read_concern;
30 class write_concern;
31 class read_preference;
32 
33 namespace options {
34 
38 class MONGOCXX_API transaction {
39  public:
40  transaction();
41 
45  transaction(const transaction&);
46 
50  transaction& operator=(const transaction&);
51 
55  transaction(transaction&&) noexcept;
56 
60  transaction& operator=(transaction&&) noexcept;
61 
65  ~transaction() noexcept;
66 
77  transaction& read_concern(const class read_concern& rc);
78 
85  stdx::optional<class read_concern> read_concern() const;
86 
97  transaction& write_concern(const class write_concern& wc);
98 
107  stdx::optional<class write_concern> write_concern() const;
108 
119  transaction& read_preference(const class read_preference& rp);
120 
127  stdx::optional<class 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 class ::mongocxx::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 MONGOCXX_INLINE_NAMESPACE_END
161 } // namespace mongocxx
162 
163 #include <mongocxx/config/postlude.hpp>
mongocxx
Top level namespace for the MongoDB C++ driver.
Definition: bulk_write.hpp:24
mongocxx::write_concern
Class representing the server-side requirement for reporting the success of a write operation.
Definition: write_concern.hpp:56
mongocxx::read_concern
A class to represent the read concern.
Definition: read_concern.hpp:54
mongocxx::read_preference
Class representing a preference for how the driver routes read operations to members of a replica set...
Definition: read_preference.hpp:63
mongocxx::options::transaction
Class representing the optional arguments for a transaction.
Definition: transaction.hpp:38