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
/
COItem.h
137 lines (102 loc) · 3.47 KB
/
COItem.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#import <Foundation/Foundation.h>
#import <EtoileFoundation/ETUUID.h>
#import "COType.h"
/**
* This is a low-level model object which makes up the contents of a commit's
* item tree. (a commit is a set of COItem plus the UUID of the root COItem.)
*
* It oversees import/export to/from plist format, delegating some of the work
* to COType+Plist.
*
*
* *NOTE*: COItem does not participate in an object graph with other COItem
* objects; it's basically a "value" object. It can contain NSSet/NSDictionary/NSArray,
* but these containers can only contain COUUID/NSData/NSNumber/NSString/COPath.
*
* See COSubtree for a higher-level model object, which uses COItem internally
* but lets you manipulate a set of COItem's as the corresponding tree of ObjC objects,
* which is easier to work with than raw COItem (but they are exactly equivelant
* in terms of the data they represent.)
*/
@interface COItem : NSObject <NSCopying, NSMutableCopying>
{
@package
ETUUID *uuid;
@protected
NSMutableDictionary *types;
NSMutableDictionary *values;
/**
* I think this makes sense to store at the COItem level.
* My hunch is we should store this here, but don't persist the
* schema names for individual properties.
*
*/
NSString *schemaName;
}
@property (nonatomic, readwrite, copy) NSString *schemaName;
/**
* designated initializer.
*/
- (id) initWithUUID: (ETUUID *)aUUID
typesForAttributes: (NSDictionary *)typesForAttributes
valuesForAttributes: (NSDictionary *)valuesForAttributes;
- (id) initWithUUID: (ETUUID *)aUUID;
+ (COItem *) itemWithTypesForAttributes: (NSDictionary *)typesForAttributes
valuesForAttributes: (NSDictionary *)valuesForAttributes;
+ (COItem *) itemWithUUID: (ETUUID *)aUUID;
- (ETUUID *) UUID;
- (NSArray *) attributeNames;
- (COType) typeForAttribute: (NSString *)anAttribute;
- (id) valueForAttribute: (NSString*)anAttribute;
/** @taskunit convenience */
// allows treating primitive or container, unordered or ordered as NSArray
- (NSArray*) allObjectsForAttribute: (NSString*)attribute;
- (NSSet *) embeddedItemUUIDs;
- (NSSet *) referencedItemUUIDs;
// GC helper methods
- (NSArray *) attachments;
- (NSArray *) allReferencedPersistentRootUUIDs;
- (NSString *) fullTextSearchContent;
/** @taskunit NSCopying and NSMutableCopying */
- (id)copyWithZone:(NSZone *)zone;
- (id)mutableCopyWithZone:(NSZone *)zone;
/**
* Returns a mutable item
*/
- (id)mutableCopyWithNameMapping: (NSDictionary *)aMapping;
@end
@interface COMutableItem : COItem
{
}
- (id) initWithUUID: (ETUUID*)aUUID;
+ (COMutableItem *) itemWithTypesForAttributes: (NSDictionary *)typesForAttributes
valuesForAttributes: (NSDictionary *)valuesForAttributes;
/**
* new item with new UIID
*/
+ (COMutableItem *) item;
- (void) setUUID: (ETUUID *)aUUID;
- (void) setValue: (id)aValue
forAttribute: (NSString*)anAttribute
type: (COType)aType;
- (void)removeValueForAttribute: (NSString*)anAttribute;
/**
* Creates the container if needed.
*/
- (void) addObject: (id)aValue
toUnorderedAttribute: (NSString*)anAttribute
type: (COType)aType;
/**
* Creates the container if needed.
*/
- (void) addObject: (id)aValue
toOrderedAttribute: (NSString*)anAttribute
atIndex: (NSUInteger)anIndex
type: (COType)aType;
/** @taskunit convenience */
- (void) addObject: (id)aValue
forAttribute: (NSString*)anAttribute;
- (void) setValue: (id)aValue
forAttribute: (NSString*)anAttribute;
- (id) copyWithZone:(NSZone *)zone;
@end