Rename realm delegate in transact_log_handler as well

This commit is contained in:
Kristian Dupont 2015-10-29 13:16:36 +01:00
parent 4973827531
commit 70e1967782
2 changed files with 25 additions and 25 deletions

View File

@ -18,7 +18,7 @@
#include "transact_log_handler.hpp"
#include "realm_delegate.hpp"
#include "../realm_binding_context.hpp"
#include <realm/commit_log.hpp>
#include <realm/group_shared.hpp>
@ -28,15 +28,15 @@ using namespace realm;
namespace {
class TransactLogHandler {
using ColumnInfo = RealmDelegate::ColumnInfo;
using ObserverState = RealmDelegate::ObserverState;
using ColumnInfo = RealmBindingContext::ColumnInfo;
using ObserverState = RealmBindingContext::ObserverState;
// Observed table rows which need change information
std::vector<ObserverState> m_observers;
// Userdata pointers for rows which have been deleted
std::vector<void *> invalidated;
// Delegate to send change information to
RealmDelegate* m_delegate;
RealmBindingContext* m_binding_context;
// Index of currently selected table
size_t m_current_table = 0;
@ -84,33 +84,33 @@ class TransactLogHandler {
public:
template<typename Func>
TransactLogHandler(RealmDelegate* delegate, SharedGroup& sg, Func&& func)
: m_delegate(delegate)
TransactLogHandler(RealmBindingContext* binding_context, SharedGroup& sg, Func&& func)
: m_binding_context(binding_context)
{
if (!delegate) {
if (!binding_context) {
func();
return;
}
m_observers = delegate->get_observed_rows();
m_observers = binding_context->get_observed_rows();
if (m_observers.empty()) {
auto old_version = sg.get_version_of_current_transaction();
func();
if (old_version != sg.get_version_of_current_transaction()) {
delegate->did_change({}, {});
binding_context->did_change({}, {});
}
return;
}
func(*this);
delegate->did_change(m_observers, invalidated);
binding_context->did_change(m_observers, invalidated);
}
// Called at the end of the transaction log immediately before the version
// is advanced
void parse_complete()
{
m_delegate->will_change(m_observers, invalidated);
m_binding_context->will_change(m_observers, invalidated);
}
// These would require having an observer before schema init
@ -318,28 +318,28 @@ public:
namespace realm {
namespace _impl {
namespace transaction {
void advance(SharedGroup& sg, ClientHistory& history, RealmDelegate* delegate) {
TransactLogHandler(delegate, sg, [&](auto&&... args) {
void advance(SharedGroup& sg, ClientHistory& history, RealmBindingContext* binding_context) {
TransactLogHandler(binding_context, sg, [&](auto&&... args) {
LangBindHelper::advance_read(sg, history, std::move(args)...);
});
}
void begin(SharedGroup& sg, ClientHistory& history, RealmDelegate* delegate) {
TransactLogHandler(delegate, sg, [&](auto&&... args) {
void begin(SharedGroup& sg, ClientHistory& history, RealmBindingContext* binding_context) {
TransactLogHandler(binding_context, sg, [&](auto&&... args) {
LangBindHelper::promote_to_write(sg, history, std::move(args)...);
});
}
void commit(SharedGroup& sg, ClientHistory&, RealmDelegate* delegate) {
void commit(SharedGroup& sg, ClientHistory&, RealmBindingContext* binding_context) {
LangBindHelper::commit_and_continue_as_read(sg);
if (delegate) {
delegate->did_change({}, {});
if (binding_context) {
binding_context->did_change({}, {});
}
}
void cancel(SharedGroup& sg, ClientHistory& history, RealmDelegate* delegate) {
TransactLogHandler(delegate, sg, [&](auto&&... args) {
void cancel(SharedGroup& sg, ClientHistory& history, RealmBindingContext* binding_context) {
TransactLogHandler(binding_context, sg, [&](auto&&... args) {
LangBindHelper::rollback_and_continue_as_read(sg, history, std::move(args)...);
});
}

View File

@ -20,7 +20,7 @@
#define REALM_TRANSACT_LOG_HANDLER_HPP
namespace realm {
class RealmDelegate;
class RealmBindingContext;
class SharedGroup;
class ClientHistory;
@ -28,19 +28,19 @@ namespace _impl {
namespace transaction {
// Advance the read transaction version, with change notifications sent to delegate
// Must not be called from within a write transaction.
void advance(SharedGroup& sg, ClientHistory& history, RealmDelegate* delegate);
void advance(SharedGroup& sg, ClientHistory& history, RealmBindingContext* binding_context);
// Begin a write transaction
// If the read transaction version is not up to date, will first advance to the
// most recent read transaction and sent notifications to delegate
void begin(SharedGroup& sg, ClientHistory& history, RealmDelegate* delegate);
void begin(SharedGroup& sg, ClientHistory& history, RealmBindingContext* binding_context);
// Commit a write transaction
void commit(SharedGroup& sg, ClientHistory& history, RealmDelegate* delegate);
void commit(SharedGroup& sg, ClientHistory& history, RealmBindingContext* binding_context);
// Cancel a write transaction and roll back all changes, with change notifications
// for reverting to the old values sent to delegate
void cancel(SharedGroup& sg, ClientHistory& history, RealmDelegate* delegate);
void cancel(SharedGroup& sg, ClientHistory& history, RealmBindingContext* binding_context);
} // namespace transaction
} // namespace _impl
} // namespace realm