ObjectAL
 All Classes Functions Variables Properties Pages
Instance Methods | Class Methods | Protected Attributes | Properties | List of all members
OALSuspendHandler Class Reference

Provides two controls (interrupted and manuallySuspended) for suspending a slave object, and also propagates such control messages to interested listeners. More...

#import <OALSuspendHandler.h>

Inheritance diagram for OALSuspendHandler:

Instance Methods

(id) - initWithTarget:selector:
 Initialize a handler with the specified slave target and selector. More...
 
(void) - addSuspendListener:
 Add a listener that will receive manual suspend and interrupt events. More...
 
(void) - removeSuspendListener:
 Remove a registered listener. More...
 

Class Methods

(OALSuspendHandler *) + handlerWithTarget:selector:
 Create a new handler with the specified slave target and selector. More...
 

Protected Attributes

NSMutableArray * listeners
 Listeners that will receive manualSuspend and interrupt events. More...
 
NSMutableArray * manualSuspendStates
 Holder for the state of manualSuspend in listeners when this object is manually suspended. More...
 
SEL suspendStatusChangeSelector
 Selector to be invoked on suspend or unsuspend. More...
 
bool manualSuspendLock
 Holds the current "manually suspended" state. More...
 
bool interruptLock
 Holds the current "interrupted" state. More...
 

Properties

bool manuallySuspended
 If YES, the manual suspend control is set. More...
 
bool interrupted
 If YES, the interrupt control is set. More...
 
bool suspended
 If YES, the slave object is suspended. More...
 

Detailed Description

Provides two controls (interrupted and manuallySuspended) for suspending a slave object, and also propagates such control messages to interested listeners.

"interrupted" is meant to be set by the system when an interrupt occurs.

"manuallySuspended" is a user-settable control for suspending an object.
"manuallySuspended" also has an extra step in its processing: When set, the handler makes a note of what its listeners' "manuallySuspended" values are. When cleared, it will only clear a listener's "manuallySuspended" value if it was not set at suspend time. This allows for ad-hoc setting/clearing of "manuallySuspended" in the middle of a handler/listener graph rather than only from the top level.

When either control is set, the slave object will be suspended. When both are cleared, the slave object will be unsuspended.

Method Documentation

- (void) addSuspendListener: (id<OALSuspendListener>)  listener

Add a listener that will receive manual suspend and interrupt events.

Parameters
listenerThe listener to register with this handler.
+ (OALSuspendHandler *) handlerWithTarget: (id)  target
selector: (SEL)  selector 

Create a new handler with the specified slave target and selector.

The selector provided must take a single boolean value like so:

  • (void) setSuspended:(bool) value
Parameters
targetThe slave object that will receive suspend/unsuspend events.
selectorThe selector for a "set suspended" method, taking a single boolean parameter.
- (id) initWithTarget: (id)  target
selector: (SEL)  selector 

Initialize a handler with the specified slave target and selector.

The selector provided must take a single boolean value like so:

  • (void) setSuspended:(bool) value
Parameters
targetThe slave object that will receive suspend/unsuspend events.
selectorThe selector for a "set suspended" method, taking a single boolean parameter.
- (void) removeSuspendListener: (id<OALSuspendListener>)  listener

Remove a registered listener.

Parameters
listenerThe listener to unregister from this handler.

Member Data Documentation

- (bool) interruptLock
protected

Holds the current "interrupted" state.

- (NSMutableArray*) listeners
protected

Listeners that will receive manualSuspend and interrupt events.

- (bool) manualSuspendLock
protected

Holds the current "manually suspended" state.

- (NSMutableArray*) manualSuspendStates
protected

Holder for the state of manualSuspend in listeners when this object is manually suspended.

- (SEL) suspendStatusChangeSelector
protected

Selector to be invoked on suspend or unsuspend.

Takes the signature: setSelected:(bool) value

Property Documentation

- (bool) interrupted
readwritenonatomicassign

If YES, the interrupt control is set.

- (bool) manuallySuspended
readwritenonatomicassign

If YES, the manual suspend control is set.

- (bool) suspended
readnonatomicassign

If YES, the slave object is suspended.


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