Class TObserver

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TObserver = class(TComponent)

Description

TObserver is used to coordinate when TDataArrays need to be updated.

Hierarchy

Overview

Fields

Private FObserved: boolean;
Private FObserver: IObjectObserver;
Private FObserverList: IObjectObserverList;
Private FOnNotify: TNotifyEvent;
Private FOnUpToDateSet: TNotifyEvent;
Private FSubscribers: TList;
Private FUpToDate: boolean;

Methods

Private function GetName: TComponentName;
Private function GetSubject: ISubject;
Protected procedure SetName(const Value: TComponentName); override;
Protected procedure SetUpToDate(const Value: boolean); virtual;
Public constructor Create(AnOwner: TComponent); override;
Public destructor Destroy; override;
Public function IsRecursive: boolean;
Public procedure ObserverNotification(Kind: TNotificationKInd; Obj: TObject; ChangeKind: TChangeKind); virtual;
Public procedure RemoveAllSubscriptions;
Public procedure Subscribe(const Observer: TObserver);
Public procedure Unsubscribe(const Observer: TObserver);
Public procedure UpdateWithName(const AName: string); virtual;

Properties

Private property Observer: IObjectObserver read FObserver;
Private property Subject: ISubject read GetSubject;
Protected property Observed: boolean read FObserved write FObserved;
Public property ObserverList: IObjectObserverList read FObserverList;
Public property UpToDate: boolean read FUpToDate write SetUpToDate;
Published property Name: TComponentName read GetName write SetName;
Published property OnNotify: TNotifyEvent read FOnNotify write FOnNotify;
Published property OnUpToDateSet: TNotifyEvent read FOnUpToDateSet write FOnUpToDateSet;

Description

Fields

Private FObserved: boolean;

FObserved: boolean; See Observed.

Private FObserver: IObjectObserver;

FObserver: IObjectObserver; IObjectObserver is defined in ObserverIntfU. See Observer.

Private FObserverList: IObjectObserverList;

FObserverList: IObjectObserverList; IObjectObserverList is defined in ObserverIntfU. See ObserverList.

Private FOnNotify: TNotifyEvent;

FOnNotify: TNotifyEvent; See OnNotify.

Private FOnUpToDateSet: TNotifyEvent;

FOnUpToDateSet: TNotifyEvent; See OnUpToDateSet.

Private FSubscribers: TList;

FSubscribers: TList; FSubscribers is a list of (TObserver)s that should be notified when there is a change in the current object.

Private FUpToDate: boolean;

FUpToDate: boolean; See UpToDate.

Methods

Private function GetName: TComponentName;

See Name.

Private function GetSubject: ISubject;

See Subject.

Protected procedure SetName(const Value: TComponentName); override;

See Name.

Protected procedure SetUpToDate(const Value: boolean); virtual;

See UpToDate.

Public constructor Create(AnOwner: TComponent); override;

Create creates an instance of TObserver.

Public destructor Destroy; override;

Destroy destroys the current instance of TObserver. Do not call Destroy directly. Call Free instead.

Public function IsRecursive: boolean;

IsRecursive checks whether an instance of IsRecursive is directly or indirectly observing itself. IsRecursive should always return false because if it is observing itself, there has been an error.

Public procedure ObserverNotification(Kind: TNotificationKInd; Obj: TObject; ChangeKind: TChangeKind); virtual;

ObserverNotification responds to ChangeKind = ckResetObserved be setting Observed to false for itself and everything that observes it. ObserverNotification responds to ChangeKind = ckCheckDependance by setting Observed to true for itself and everything that observes it. For any other value of ChangeKind, it sets UpToDate to false. If UpToDate was True, it calls ObserverList.NotifyOnChange. ObserverNotification also call OnNotify.

Public procedure RemoveAllSubscriptions;

RemoveAllSubscriptions removes all subscribers to the current object. See Unsubscribe. RemoveAllSubscriptions is called in Destroy.

Public procedure Subscribe(const Observer: TObserver);

Subscribe causes Observer to be notified when there is a change in this object. Subscribe calls

     Subject.Subscribe(Observer.Observer);
    

See Unsubscribe, Subject, and Observer.

Public procedure Unsubscribe(const Observer: TObserver);

Unsubscribe removes Observer from the list of items to be notified when there is a change in this object. See Subscribe and RemoveAllSubscriptions.

Public procedure UpdateWithName(const AName: string); virtual;

UpdateWithName assigns Name := AName.

Properties

Private property Observer: IObjectObserver read FObserver;

Observer is an interface implemented as a TObjectObserver which is used in handling subscriptions. See Subscribe. TObjectObserver is defined in ObserverU.

Private property Subject: ISubject read GetSubject;

Subject is an interface implemented as a ObserverListU.TObserverlist which is used in handling subscriptions. See Subscribe.

Protected property Observed: boolean read FObserved write FObserved;

Observed is used in IsRecursive to see if a TObserver is observing itself.

Public property ObserverList: IObjectObserverList read FObserverList;

ObserverList is an interface to a list of the objects which observe the current object.

Public property UpToDate: boolean read FUpToDate write SetUpToDate;

UpToDate indicates whether the current TObserver is up-to-date. Changing UpToDate from True to False will call all the things that observe the current TObserver to also have their UpToDate set to false.

Published property Name: TComponentName read GetName write SetName;

Name is the name of the TObserver.

Published property OnNotify: TNotifyEvent read FOnNotify write FOnNotify;

OnNotify is called in ObserverNotification;

Published property OnUpToDateSet: TNotifyEvent read FOnUpToDateSet write FOnUpToDateSet;

OnUpToDateSet is called whenever UpToDate is set even if UpToDate is not changed.


Generated by PasDoc 0.10.0 on 2006-10-31 09:56:47