1 ////////////////////////////////////////////////////////////////////////////
3 // Copyright 2015 Realm Inc.
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
17 ////////////////////////////////////////////////////////////////////////////
19 #ifndef REALM_TRANSACT_LOG_HANDLER_HPP
20 #define REALM_TRANSACT_LOG_HANDLER_HPP
23 #include <realm/version_id.hpp>
32 class NotifierPackage;
33 struct TransactionChangeInfo;
35 namespace transaction {
36 // Advance the read transaction version, with change notifications sent to delegate
37 // Must not be called from within a write transaction.
38 void advance(const std::unique_ptr<SharedGroup>& sg, BindingContext* binding_context, NotifierPackage&);
39 void advance(SharedGroup& sg, BindingContext* binding_context, VersionID);
41 // Begin a write transaction
42 // If the read transaction version is not up to date, will first advance to the
43 // most recent read transaction and sent notifications to delegate
44 void begin(const std::unique_ptr<SharedGroup>& sg, BindingContext* binding_context, NotifierPackage&);
45 void begin_without_validation(SharedGroup& sg);
47 // Commit a write transaction
48 void commit(SharedGroup& sg);
50 // Cancel a write transaction and roll back all changes, with change notifications
51 // for reverting to the old values sent to delegate
52 void cancel(SharedGroup& sg, BindingContext* binding_context);
54 // Advance the read transaction version, with change information gathered in info
55 void advance(SharedGroup& sg, TransactionChangeInfo& info, VersionID version=VersionID{});
56 } // namespace transaction
60 #endif /* REALM_TRANSACT_LOG_HANDLER_HPP */