123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- #import <Foundation/Foundation.h>
- #import "binding_context.hpp"
- #import <realm/obj.hpp>
- #import <realm/table.hpp>
- #import <unordered_map>
- @class RLMObjectBase, RLMRealm, RLMSchema, RLMProperty, RLMObjectSchema;
- class RLMClassInfo;
- class RLMSchemaInfo;
- namespace realm {
- class History;
- class SharedGroup;
- }
- class RLMObservationInfo {
- public:
- RLMObservationInfo(id object);
- RLMObservationInfo(RLMClassInfo &objectSchema, realm::ObjKey row, id object);
- ~RLMObservationInfo();
- realm::ConstObj const& getRow() const {
- return row;
- }
- NSString *columnName(realm::ColKey col) const noexcept;
-
-
- void willChange(NSString *key, NSKeyValueChange kind=NSKeyValueChangeSetting, NSIndexSet *indexes=nil) const;
- void didChange(NSString *key, NSKeyValueChange kind=NSKeyValueChangeSetting, NSIndexSet *indexes=nil) const;
- bool isForRow(realm::ObjKey key) const {
- return row.get_key() == key;
- }
- void recordObserver(realm::Obj& row, RLMClassInfo *objectInfo, RLMObjectSchema *objectSchema, NSString *keyPath);
- void removeObserver();
- bool hasObservers() const { return observerCount > 0; }
-
-
-
-
-
-
-
-
-
-
-
-
- id valueForKey(NSString *key);
- void prepareForInvalidation();
- private:
-
- RLMObservationInfo *next = nullptr;
- RLMObservationInfo *prev = nullptr;
-
- realm::ConstObj row;
- RLMClassInfo *objectSchema = nullptr;
-
- __unsafe_unretained id object = nil;
-
- bool invalidated = false;
- size_t observerCount = 0;
- NSString *lastKey = nil;
- __unsafe_unretained RLMProperty *lastProp = nil;
-
-
- NSMutableDictionary *cachedObjects;
- void setRow(realm::Table const& table, realm::ObjKey newRow);
- template<typename F>
- void forEach(F&& f) const {
-
-
-
-
- __attribute__((objc_precise_lifetime)) id self = object, current;
- for (auto info = prev; info; info = info->prev) {
- current = info->object;
- f(info->object);
- }
- for (auto info = this; info; info = info->next) {
- current = info->object;
- f(info->object);
- }
- }
-
-
- RLMObservationInfo(RLMObservationInfo const&) = delete;
- RLMObservationInfo(RLMObservationInfo&&) = delete;
- RLMObservationInfo& operator=(RLMObservationInfo const&) = delete;
- RLMObservationInfo& operator=(RLMObservationInfo&&) = delete;
- };
- RLMObservationInfo *RLMGetObservationInfo(RLMObservationInfo *info, realm::ObjKey row, RLMClassInfo& objectSchema);
- void RLMClearTable(RLMClassInfo &realm);
- void RLMTrackDeletions(RLMRealm *realm, dispatch_block_t block);
- std::vector<realm::BindingContext::ObserverState> RLMGetObservedRows(RLMSchemaInfo const& schema);
- void RLMWillChange(std::vector<realm::BindingContext::ObserverState> const& observed, std::vector<void *> const& invalidated);
- void RLMDidChange(std::vector<realm::BindingContext::ObserverState> const& observed, std::vector<void *> const& invalidated);
|