integrate latest object store changes
This commit is contained in:
parent
638ee4d3b4
commit
e4732994b7
|
@ -18,25 +18,23 @@
|
||||||
|
|
||||||
#include "transact_log_handler.hpp"
|
#include "transact_log_handler.hpp"
|
||||||
|
|
||||||
#include "../realm_binding_context.hpp"
|
#include "../binding_context.hpp"
|
||||||
|
|
||||||
#include <realm/commit_log.hpp>
|
#include <realm/commit_log.hpp>
|
||||||
#include <realm/group_shared.hpp>
|
#include <realm/group_shared.hpp>
|
||||||
#include <realm/lang_bind_helper.hpp>
|
#include <realm/lang_bind_helper.hpp>
|
||||||
|
|
||||||
using namespace realm;
|
namespace realm {
|
||||||
|
|
||||||
namespace {
|
|
||||||
class TransactLogHandler {
|
class TransactLogHandler {
|
||||||
using ColumnInfo = RealmBindingContext::ColumnInfo;
|
using ColumnInfo = BindingContext::ColumnInfo;
|
||||||
using ObserverState = RealmBindingContext::ObserverState;
|
using ObserverState = BindingContext::ObserverState;
|
||||||
|
|
||||||
// Observed table rows which need change information
|
// Observed table rows which need change information
|
||||||
std::vector<ObserverState> m_observers;
|
std::vector<ObserverState> m_observers;
|
||||||
// Userdata pointers for rows which have been deleted
|
// Userdata pointers for rows which have been deleted
|
||||||
std::vector<void *> invalidated;
|
std::vector<void *> invalidated;
|
||||||
// Delegate to send change information to
|
// Delegate to send change information to
|
||||||
RealmBindingContext* m_binding_context;
|
BindingContext* m_binding_context;
|
||||||
|
|
||||||
// Index of currently selected table
|
// Index of currently selected table
|
||||||
size_t m_current_table = 0;
|
size_t m_current_table = 0;
|
||||||
|
@ -84,7 +82,7 @@ class TransactLogHandler {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
template<typename Func>
|
template<typename Func>
|
||||||
TransactLogHandler(RealmBindingContext* binding_context, SharedGroup& sg, Func&& func)
|
TransactLogHandler(BindingContext* binding_context, SharedGroup& sg, Func&& func)
|
||||||
: m_binding_context(binding_context)
|
: m_binding_context(binding_context)
|
||||||
{
|
{
|
||||||
if (!binding_context) {
|
if (!binding_context) {
|
||||||
|
@ -325,19 +323,19 @@ public:
|
||||||
namespace realm {
|
namespace realm {
|
||||||
namespace _impl {
|
namespace _impl {
|
||||||
namespace transaction {
|
namespace transaction {
|
||||||
void advance(SharedGroup& sg, ClientHistory& history, RealmBindingContext* binding_context) {
|
void advance(SharedGroup& sg, ClientHistory& history, BindingContext* binding_context) {
|
||||||
TransactLogHandler(binding_context, sg, [&](auto&&... args) {
|
TransactLogHandler(binding_context, sg, [&](auto&&... args) {
|
||||||
LangBindHelper::advance_read(sg, history, std::move(args)...);
|
LangBindHelper::advance_read(sg, history, std::move(args)...);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void begin(SharedGroup& sg, ClientHistory& history, RealmBindingContext* binding_context) {
|
void begin(SharedGroup& sg, ClientHistory& history, BindingContext* binding_context) {
|
||||||
TransactLogHandler(binding_context, sg, [&](auto&&... args) {
|
TransactLogHandler(binding_context, sg, [&](auto&&... args) {
|
||||||
LangBindHelper::promote_to_write(sg, history, std::move(args)...);
|
LangBindHelper::promote_to_write(sg, history, std::move(args)...);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void commit(SharedGroup& sg, ClientHistory&, RealmBindingContext* binding_context) {
|
void commit(SharedGroup& sg, ClientHistory&, BindingContext* binding_context) {
|
||||||
LangBindHelper::commit_and_continue_as_read(sg);
|
LangBindHelper::commit_and_continue_as_read(sg);
|
||||||
|
|
||||||
if (binding_context) {
|
if (binding_context) {
|
||||||
|
@ -345,7 +343,7 @@ void commit(SharedGroup& sg, ClientHistory&, RealmBindingContext* binding_contex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cancel(SharedGroup& sg, ClientHistory& history, RealmBindingContext* binding_context) {
|
void cancel(SharedGroup& sg, ClientHistory& history, BindingContext* binding_context) {
|
||||||
TransactLogHandler(binding_context, sg, [&](auto&&... args) {
|
TransactLogHandler(binding_context, sg, [&](auto&&... args) {
|
||||||
LangBindHelper::rollback_and_continue_as_read(sg, history, std::move(args)...);
|
LangBindHelper::rollback_and_continue_as_read(sg, history, std::move(args)...);
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#define REALM_TRANSACT_LOG_HANDLER_HPP
|
#define REALM_TRANSACT_LOG_HANDLER_HPP
|
||||||
|
|
||||||
namespace realm {
|
namespace realm {
|
||||||
class RealmBindingContext;
|
class BindingContext;
|
||||||
class SharedGroup;
|
class SharedGroup;
|
||||||
class ClientHistory;
|
class ClientHistory;
|
||||||
|
|
||||||
|
@ -28,19 +28,19 @@ namespace _impl {
|
||||||
namespace transaction {
|
namespace transaction {
|
||||||
// Advance the read transaction version, with change notifications sent to delegate
|
// Advance the read transaction version, with change notifications sent to delegate
|
||||||
// Must not be called from within a write transaction.
|
// Must not be called from within a write transaction.
|
||||||
void advance(SharedGroup& sg, ClientHistory& history, RealmBindingContext* binding_context);
|
void advance(SharedGroup& sg, ClientHistory& history, BindingContext* binding_context);
|
||||||
|
|
||||||
// Begin a write transaction
|
// Begin a write transaction
|
||||||
// If the read transaction version is not up to date, will first advance to the
|
// If the read transaction version is not up to date, will first advance to the
|
||||||
// most recent read transaction and sent notifications to delegate
|
// most recent read transaction and sent notifications to delegate
|
||||||
void begin(SharedGroup& sg, ClientHistory& history, RealmBindingContext* binding_context);
|
void begin(SharedGroup& sg, ClientHistory& history, BindingContext* binding_context);
|
||||||
|
|
||||||
// Commit a write transaction
|
// Commit a write transaction
|
||||||
void commit(SharedGroup& sg, ClientHistory& history, RealmBindingContext* binding_context);
|
void commit(SharedGroup& sg, ClientHistory& history, BindingContext* binding_context);
|
||||||
|
|
||||||
// Cancel a write transaction and roll back all changes, with change notifications
|
// Cancel a write transaction and roll back all changes, with change notifications
|
||||||
// for reverting to the old values sent to delegate
|
// for reverting to the old values sent to delegate
|
||||||
void cancel(SharedGroup& sg, ClientHistory& history, RealmBindingContext* binding_context);
|
void cancel(SharedGroup& sg, ClientHistory& history, BindingContext* binding_context);
|
||||||
} // namespace transaction
|
} // namespace transaction
|
||||||
} // namespace _impl
|
} // namespace _impl
|
||||||
} // namespace realm
|
} // namespace realm
|
||||||
|
|
|
@ -203,7 +203,9 @@ bool Realm::update_schema(std::unique_ptr<Schema> schema, uint64_t version)
|
||||||
auto migration_function = [&](Group*, Schema&) {
|
auto migration_function = [&](Group*, Schema&) {
|
||||||
SharedRealm old_realm(new Realm(old_config));
|
SharedRealm old_realm(new Realm(old_config));
|
||||||
auto updated_realm = shared_from_this();
|
auto updated_realm = shared_from_this();
|
||||||
|
if (m_config.migration_function) {
|
||||||
m_config.migration_function(old_realm, updated_realm);
|
m_config.migration_function(old_realm, updated_realm);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue