BNZObserverRecord



Abstract

an internal class used by the BNZTransactionalNotificationCenter to manage registrations

Discussion

This class is used by the BNZTransactionalNotificationCenter to manage registrations of objects to be informed about changes on certain other objects. The objects that want to be informed are called "TransactionObserver", because they participate in the commit phase of all transactions that contains a change they registered for.

This class holds the observer reference and manages the individual observation record objects that are created whenever a registerTransactionObserver in BNZTransactionalNotificationCenter is called.

For each observer, the BNZTransactionalNotificationCenter maintains one observer record to contain all its single observation records.



Methods

exactObservationForChangeType:onTarget:

Abstract: returns the observation record that contains the exact type and target.
- (BNZObservation*)observationForChangeType:(id)changeType onTarget:(id)target; 

returns the observation record that contains the exact type and target. there may only be one observation of the same changetype on the same target (including the cases where change type or target are nil)

Result: the observation for the given params, if existing. nil else

initWithObserver:

Abstract: create a new record object
- (id)initWithObserver:(id)observer; 

Parameters

NameDescription
observerthe observer for this record
Result: a new record object

isEmpty

- (BOOL)isEmpty; 

Result: YES if no observations are contained in this record, NO otherwise

observationsForChange:

Abstract: find all observations that match the given change
- (NSArray*)stateDependentObservationsForChange:(id)change inCallback:(SEL)callback; 

Parameters

NameDescription
changethe change for wich all observations shall be found
Result: an array containing all matching BNZObservation records

observationsForChange:

- (NSArray*)observationsForChange:(id)change; 

Parameters

NameDescription
changea given change
Result: all observations that match the change

observer

- (id)observer; 

Result: returns the observer for this record

removeObservationForChangeType:onTarget:

Abstract: remove the observation of the given type on the target
-  removeObservationForChangeType:(id)changeType onTarget:(id)target; 

Parameters

NameDescription
changeTypethe type of the observed changes, or nil for all
targetthe observed object for changes, of nil for all
Result: returns self

setObservationForChangeType:onTarget:

Abstract: set a new observation
-  setObservation:(BNZObservation*)observation; 

a call on registerTransactionObserver in BNZTransactionalNotificationCenter results in a call to this method

Will overwrite a previous observation of the same type on the same target, if present (hence "set" because there can only be one observation of the same type on the same target for the same observer)

Parameters

NameDescription
observationthe observation object
Result: returns self

(Last Updated 8/31/2006)