MongoDB C++ Driver current
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
25namespace mongocxx {
26MONGOCXX_INLINE_NAMESPACE_BEGIN
27
28class client_session;
29class read_concern;
30class write_concern;
31class read_preference;
32
33namespace options {
34
38class MONGOCXX_API transaction {
39 public:
41
46
51
56
60 transaction& operator=(transaction&&) noexcept;
61
65 ~transaction() noexcept;
66
78
85 stdx::optional<class read_concern> read_concern() const;
86
98
107 stdx::optional<class write_concern> write_concern() const;
108
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
160MONGOCXX_INLINE_NAMESPACE_END
161} // namespace mongocxx
162
163#include <mongocxx/config/postlude.hpp>
Class representing the optional arguments to mongocxx::client::start_session.
Definition: client_session.hpp:30
Class representing the optional arguments for a transaction.
Definition: transaction.hpp:38
transaction & operator=(const transaction &)
Copy assigns transaction options.
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:54
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:56
Top level namespace for the MongoDB C++ driver.
Definition: bulk_write.hpp:24