This repository has been archived by the owner on Jul 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCOItemGraph.h
63 lines (50 loc) · 1.49 KB
/
COItemGraph.h
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
#import <Foundation/Foundation.h>
@class ETUUID;
@class COItem;
/**
* Protocol for a mutable item graph
*
* The object model is:
* All objects must have a composite or non-composite relationship path to the root
* (garbage-collected graph approach). This can be violated in the short term while
* making a batch of changes.
*
* Garbage collection is not covered by this protocol.
*/
@protocol COItemGraph <NSObject>
- (ETUUID *) rootItemUUID;
/**
* Returns immutable item
*/
- (COItem *) itemForUUID: (ETUUID *)aUUID;
- (NSArray *) itemUUIDs;
/**
* Insert or update an item
*/
- (void) addItem: (COItem *)anItem;
@end
/**
* An item tree is just a mutable set of COItem objects along
* with the UUID of the root object.
*
* However, there is no guarantee that the items form a complete tree,
* or even that the item for the root UUID is in the set of items.
*
* The intended use for COItemTree is as a really simple
* delta mechanism, so you can compute (COItemTree + COItemTree) = a new COItemTree
*/
@interface COItemGraph : NSObject <COItemGraph>
{
ETUUID *rootItemUUID_;
NSMutableDictionary *itemForUUID_;
}
+ (COItemGraph *)treeWithItemsRootFirst: (NSArray*)items;
- (id) initWithItemForUUID: (NSDictionary *) itemForUUID
rootItemUUID: (ETUUID *)root;
- (id) initWithItems: (NSArray *)items
rootItemUUID: (ETUUID *)root;
- (ETUUID *) rootItemUUID;
- (COItem *) itemForUUID: (ETUUID *)aUUID;
- (NSArray *) itemUUIDs;
- (void) addItem: (COItem *)anItem;
@end