Oolite
Loading...
Searching...
No Matches
OOFilteringEnumerator Class Reference

#include <OOFilteringEnumerator.h>

Inheritance diagram for OOFilteringEnumerator:
Collaboration diagram for OOFilteringEnumerator:

Instance Methods

(id) - initWithUnderlyingEnumerator:withSelector:takingArgument:argumentValue:
(void) - dealloc [implementation]
(NSString *) - descriptionComponents [implementation]
(NSString *) - shortDescriptionComponents [implementation]
(id) - nextObject [implementation]

Class Methods

(id) + filterEnumerator:withSelector:
(id) + filterEnumerator:withSelector:andArgument:

Private Attributes

NSEnumerator * _underlyingEnum
SEL _selector
id _argument
BOOL _takesArgument

Detailed Description

Definition at line 56 of file OOFilteringEnumerator.h.

Method Documentation

◆ dealloc

- (void) dealloc
implementation

Definition at line 77 of file OOFilteringEnumerator.m.

78{
79 [_underlyingEnum release];
80 [_argument release];
81
82 [super dealloc];
83}

References dealloc.

Referenced by dealloc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ descriptionComponents

- (NSString *) descriptionComponents
implementation

Definition at line 85 of file OOFilteringEnumerator.m.

86{
87 NSString* subDesc = NSStringFromSelector(_selector);
88 if (_takesArgument) {
89 subDesc = [subDesc stringByAppendingString:[_argument shortDescription]];
90 }
91
92 return [NSString stringWithFormat:@"%@ matching %@", [_underlyingEnum shortDescription], subDesc];
93}

References _selector, _takesArgument, and descriptionComponents.

Referenced by descriptionComponents.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ filterEnumerator:withSelector:

+ (id) filterEnumerator: (NSEnumerator*) enumerator
withSelector: (SEL) selector 

Definition at line 36 of file OOFilteringEnumerator.m.

36 :(NSEnumerator*)enumerator withSelector:(SEL)selector
37{
38 if (selector == NULL)
39 return [[enumerator retain] autorelease];
40
41 return [[[self alloc] initWithUnderlyingEnumerator:enumerator
42 withSelector:selector
43 takingArgument:NO
44 argumentValue:nil]
45 autorelease];
46}

Referenced by NSEnumerator(OOFilteringEnumerator)::filteredWithSelector:.

Here is the caller graph for this function:

◆ filterEnumerator:withSelector:andArgument:

+ (id) filterEnumerator: (NSEnumerator*) enumerator
withSelector: (SEL) selector
andArgument: (id) argument 

Definition at line 48 of file OOFilteringEnumerator.m.

48 :(NSEnumerator*)enumerator withSelector:(SEL)selector andArgument:(id)argument
49{
50 if (selector == NULL)
51 return [[enumerator retain] autorelease];
52
53 return [[[self alloc] initWithUnderlyingEnumerator:enumerator
54 withSelector:selector
55 takingArgument:YES
56 argumentValue:argument]
57 autorelease];
58}

Referenced by NSEnumerator(OOFilteringEnumerator)::filteredWithSelector:andArgument:.

Here is the caller graph for this function:

◆ initWithUnderlyingEnumerator:withSelector:takingArgument:argumentValue:

- (id) initWithUnderlyingEnumerator: (NSEnumerator*) enumerator
withSelector: (SEL) selector
takingArgument: (BOOL) takesArgument
argumentValue: (id) argument 

Definition at line 60 of file OOFilteringEnumerator.m.

60 :(NSEnumerator*)enumerator
61 withSelector:(SEL)selector
62 takingArgument:(BOOL)takesArgument
63 argumentValue:(id)argument
64{
65 self = [super init];
66 if (self != nil) {
67 _underlyingEnum = [enumerator retain];
68 _selector = selector;
69 _takesArgument = takesArgument;
70 if (_takesArgument) {
71 _argument = [argument retain];
72 }
73 }
74 return self;
75}
return nil

References _argument, _selector, _takesArgument, _underlyingEnum, and nil.

◆ nextObject

- (id) nextObject
implementation

Definition at line 100 of file OOFilteringEnumerator.m.

101{
102 for (;;) {
103 // Get next object
104 id obj = [_underlyingEnum nextObject];
105 BOOL filter;
106
107 if (obj == nil) {
108 // End of enumeration
109 if (_underlyingEnum != nil) {
110 [_underlyingEnum release];
112 [_argument release];
113 _argument = nil;
114 }
115 return nil;
116 }
117
118 // Check against filter
119 IMP predicate = [obj methodForSelector:_selector];
120 if (predicate != NULL) {
121 if (!_takesArgument) {
122 filter = ((BoolReturnMsgSend)predicate)(obj, _selector);
123 } else {
124 filter = ((BoolReturnWithParamMsgSend)predicate)(obj, _selector, _argument);
125 }
126 } else {
127 // Unsupported method
128 filter = NO;
129 }
130
131 // If object passed, return it.
132 if (filter)
133 return obj;
134 }
135}
BOOL(* BoolReturnMsgSend)(id, SEL)
BOOL(* BoolReturnWithParamMsgSend)(id, SEL, id)

References _argument, _selector, _takesArgument, _underlyingEnum, nextObject, and nil.

Referenced by nextObject.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ shortDescriptionComponents

- (NSString *) shortDescriptionComponents
implementation

Definition at line 95 of file OOFilteringEnumerator.m.

96{
97 return NSStringFromSelector(_selector);
98}

References _selector, and shortDescriptionComponents.

Referenced by shortDescriptionComponents.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _argument

- (id) _argument
private

◆ _selector

◆ _takesArgument

- (BOOL) _takesArgument
private

◆ _underlyingEnum

- (NSEnumerator*) _underlyingEnum
private

The documentation for this class was generated from the following files: