-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathCOCrossPersistentRootDeadRelationshipCache.h
More file actions
68 lines (60 loc) · 2.39 KB
/
COCrossPersistentRootDeadRelationshipCache.h
File metadata and controls
68 lines (60 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
Copyright (C) 2015 Quentin Mathe
Date: May 2015
License: MIT (see COPYING)
*/
#import <Foundation/Foundation.h>
#import <EtoileFoundation/EtoileFoundation.h>
@class COPath, COObject;
NS_ASSUME_NONNULL_BEGIN
/**
* An instance of this class is owned by each COEditingContext, to cache
* incoming relationships for faulted, deleted or possibly finalized
* persistent roots.
*
* For faulted or deleted persistent roots or branches, the root object is not
* present in memory, so we cannot track incoming relationships accross
* persistent roots using the usual relationship cache that exists per object.
*
* When a persistent root or branch is unfaulted or undeleted, we use this cache
* to know which other persistent roots outgoing relationships must be fixed to
* point to the resurrected root object. To fix outgoing relationships accross
* persistent roots, we replace dead COPath references hidden in the
* COPrimitiveCollection backing by alive COObject references.
*/
@interface COCrossPersistentRootDeadRelationshipCache : NSObject
{
@private
NSMutableDictionary *_pathToReferringObjects;
NSMapTable *_referringObjectToPaths;
}
- (void)addReferringObject: (COObject *)aReferrer
forPath: (COPath *)aPath;
/**
* When no referring objects exist, returns nil.
*/
#ifdef GNUSTEP
- (nullable NSHashTable *)referringObjectsForPath: (COPath *)aPath;
#else
- (nullable NSHashTable<__kindof COObject *> *)referringObjectsForPath: (COPath *)aPath;
#endif
- (void)removeReferringObject: (COObject *)aReferrer
forPath: (COPath *)aPath;
- (void)removeReferringObject: (COObject *)aReferrer;
/**
* Removes all referring objects for the path.
*
* When a persistent root or branch is unfaulted, undeleted or finalized, this
* method should be called with a persistent root path that corresponds to the
* undeletion/finalization target.
* When a persistent root or branch is unloaded, any matching paths should be
* kept in the cache, in case it gets reloaded later (we cannot figure out cross
* persistent root incoming relationships from the reloading).
*
* For referring object graph contexts, when unloaded or finalized, the
* deallocation will trigger their removal of their inner objects from the hash
* tables in the cache on 10.8 or iOS 6 or higher, which we require.
*/
- (void)removePath: (COPath *)aPath;
@end
NS_ASSUME_NONNULL_END