-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathCOSmartGroup.h
More file actions
111 lines (89 loc) · 2.62 KB
/
Copy pathCOSmartGroup.h
File metadata and controls
111 lines (89 loc) · 2.62 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
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
/**
Copyright (C) 2010 Eric Wasylishen, Quentin Mathe
Date: November 2010
License: MIT (see COPYING)
*/
#import <Foundation/Foundation.h>
#import <EtoileFoundation/EtoileFoundation.h>
#import <CoreObject/COCollection.h>
typedef NSArray *(^COContentBlock)(void);
/**
* @group Search
* @abstract A custom group class whose content is provided by a predicate or
* code block.
*
* COSmartGroup is an immutable, ordered, weak (an object can be in any number
* of collections) collection class.
*
* Because it is an immutable collection, it isn't a COCollection subclass.
*/
@interface COSmartGroup : COObject <ETCollection>
{
@private
id <ETCollection> targetCollection;
NSPredicate *predicate;
COContentBlock contentBlock;
NSArray *content;
}
/** @taskunit Controlling the Content */
/**
* The target collection used to compute the smart group content.
*
* If a content block is provided, the target collection and predicate are ignored.
*
* If a predicate is provided and the target collection is filtered as an array
* using the predicate.
*
* If no content block or predicate are set, the target collection is used as is as
* the smart group content.
*
* See -predicate and -contentBlock.
*/
@property (nonatomic, readwrite, strong) id <ETCollection> targetCollection;
/**
* The predicate used to compute the smart group content.
*
* If a content block is provided, the predicate is ignored.
*
* If no target collection is set, the predicate is ignored.
*
* If a target collection is provided, see -targetCollection to know how the
* predicate is evaluated.
*
* See -targetCollection and -contentBlock.
*/
@property (nonatomic, readwrite, strong) NSPredicate *predicate;
/**
* The content block used to compute the smart group content.
*
* If a content block is set, both the target collection and predicate are ignored.
*
* See -targetCollection and -predicate.
*/
@property (nonatomic, readwrite, copy) COContentBlock contentBlock;
/** @taskunit Accessing the Content */
/**
* Returns the last computed smart group content.
*
* See -[ETCollection content].
*/
@property (nonatomic, readonly, strong) id content;
/** @taskunit Updating */
/**
* Forces the receiver content to be recreated by evaluating the predicate
* or content block.
*
* See also -predicate and -contentBlock.
*/
- (void)refresh;
/** @taskunit Object Matching */
/**
* Returns the first object whose identifier matches.
*
* The search is shallow, in other words limited to the objects in the receiver
* content.
*
* See -[COObject identifier].
*/
- (id)objectForIdentifier: (NSString *)anId;
@end