Rename RealmDelegate to RealmBindingContext

This commit is contained in:
Kristian Dupont 2015-10-29 10:42:56 +01:00
parent 347145b4f1
commit 4973827531
3 changed files with 22 additions and 22 deletions

View File

@ -16,8 +16,8 @@
// //
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
#ifndef REALM_DELEGATE_HPP #ifndef REALM_BINDING_CONTEXT_HPP
#define REALM_DELEGATE_HPP #define REALM_BINDING_CONTEXT_HPP
#include "index_set.hpp" #include "index_set.hpp"
@ -25,15 +25,15 @@
#include <vector> #include <vector>
namespace realm { namespace realm {
// RealmDelegate is the extension point for adding binding-specific behavior to // RealmBindingContext is the extension point for adding binding-specific behavior to
// a SharedRealm. It can be used to store additonal data associated with the // a SharedRealm. It can be used to store additonal data associated with the
// Realm which is needed by the binding, and there are several methods which // Realm which is needed by the binding, and there are several methods which
// can be overridden to receive notifications of state changes within the Realm. // can be overridden to receive notifications of state changes within the Realm.
// //
// A simple delegate implementation which lets the user register functions to be // A simple implementation which lets the user register functions to be
// called on refresh could look like the following: // called on refresh could look like the following:
// //
// class DelegateImplementation : public RealmDelegate { // class BindingContextImplementation : public RealmBindingContext {
// public: // public:
// // A token returned from add_notification that can be used to remove the // // A token returned from add_notification that can be used to remove the
// // notification later // // notification later
@ -66,9 +66,9 @@ namespace realm {
// private: // private:
// std::list<std::function<void ()>> m_registered_notifications; // std::list<std::function<void ()>> m_registered_notifications;
// }; // };
class RealmDelegate { class RealmBindingContext {
public: public:
virtual ~RealmDelegate() = default; virtual ~RealmBindingContext() = default;
// Called by the Realm when a write transaction is committed to the file by // Called by the Realm when a write transaction is committed to the file by
// a different Realm instance (possibly in a different process) // a different Realm instance (possibly in a different process)
@ -147,8 +147,8 @@ public:
}; };
}; };
inline void RealmDelegate::will_change(std::vector<ObserverState> const&, std::vector<void*> const&) { } inline void RealmBindingContext::will_change(std::vector<ObserverState> const&, std::vector<void*> const&) { }
inline void RealmDelegate::did_change(std::vector<ObserverState> const&, std::vector<void*> const&) { } inline void RealmBindingContext::did_change(std::vector<ObserverState> const&, std::vector<void*> const&) { }
} // namespace realm } // namespace realm
#endif /* REALM_DELEGATE_HPP */ #endif /* REALM_BINDING_CONTEXT_HPP */

View File

@ -19,7 +19,7 @@
#include "shared_realm.hpp" #include "shared_realm.hpp"
#include "external_commit_helper.hpp" #include "external_commit_helper.hpp"
#include "realm_delegate.hpp" #include "realm_binding_context.hpp"
#include "schema.hpp" #include "schema.hpp"
#include "transact_log_handler.hpp" #include "transact_log_handler.hpp"
@ -247,7 +247,7 @@ void Realm::begin_transaction()
// make sure we have a read transaction // make sure we have a read transaction
read_group(); read_group();
transaction::begin(*m_shared_group, *m_history, m_delegate.get()); transaction::begin(*m_shared_group, *m_history, m_binding_context.get());
m_in_transaction = true; m_in_transaction = true;
} }
@ -261,7 +261,7 @@ void Realm::commit_transaction()
} }
m_in_transaction = false; m_in_transaction = false;
transaction::commit(*m_shared_group, *m_history, m_delegate.get()); transaction::commit(*m_shared_group, *m_history, m_binding_context.get());
m_notifier->notify_others(); m_notifier->notify_others();
} }
@ -275,7 +275,7 @@ void Realm::cancel_transaction()
} }
m_in_transaction = false; m_in_transaction = false;
transaction::cancel(*m_shared_group, *m_history, m_delegate.get()); transaction::cancel(*m_shared_group, *m_history, m_binding_context.get());
} }
void Realm::invalidate() void Realm::invalidate()
@ -320,15 +320,15 @@ void Realm::notify()
verify_thread(); verify_thread();
if (m_shared_group->has_changed()) { // Throws if (m_shared_group->has_changed()) { // Throws
if (m_delegate) { if (m_binding_context) {
m_delegate->changes_available(); m_binding_context->changes_available();
} }
if (m_auto_refresh) { if (m_auto_refresh) {
if (m_group) { if (m_group) {
transaction::advance(*m_shared_group, *m_history, m_delegate.get()); transaction::advance(*m_shared_group, *m_history, m_binding_context.get());
} }
else if (m_delegate) { else if (m_binding_context) {
m_delegate->did_change({}, {}); m_binding_context->did_change({}, {});
} }
} }
} }
@ -351,7 +351,7 @@ bool Realm::refresh()
} }
if (m_group) { if (m_group) {
transaction::advance(*m_shared_group, *m_history, m_delegate.get()); transaction::advance(*m_shared_group, *m_history, m_binding_context.get());
} }
else { else {
// Create the read transaction // Create the read transaction

View File

@ -30,7 +30,7 @@ namespace realm {
class ClientHistory; class ClientHistory;
class Realm; class Realm;
class RealmCache; class RealmCache;
class RealmDelegate; class RealmBindingContext;
typedef std::shared_ptr<Realm> SharedRealm; typedef std::shared_ptr<Realm> SharedRealm;
typedef std::weak_ptr<Realm> WeakRealm; typedef std::weak_ptr<Realm> WeakRealm;
@ -120,7 +120,7 @@ namespace realm {
std::shared_ptr<_impl::ExternalCommitHelper> m_notifier; std::shared_ptr<_impl::ExternalCommitHelper> m_notifier;
public: public:
std::unique_ptr<RealmDelegate> m_delegate; std::unique_ptr<RealmBindingContext> m_binding_context;
// FIXME private // FIXME private
Group *read_group(); Group *read_group();