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;
Private FOnNameChange: TNotifyEvent;

Methods

Private function GetName: TComponentName;
Private function GetSubject: ISubject;
Private function GetObserverList: IObjectObserverList;
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 StopTalkingToAnyone;
Public procedure TalksTo(const Observer: TObserver);
Public procedure StopsTalkingTo(const Observer: TObserver);
Public procedure UpdateWithName(const AName: string); virtual;
Public function IsListeningTo(const AnotherObserver: TObserver): boolean;

Properties

Private property Observer: IObjectObserver read FObserver;
Private property Subject: ISubject read GetSubject;
Public property Observed: boolean read FObserved write FObserved;
Public property ObserverList: IObjectObserverList read GetObserverList;
Public property UpToDate: boolean read FUpToDate write SetUpToDate;
Public property OnNameChange: TNotifyEvent read FOnNameChange write FOnNameChange;
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.

Private FOnNameChange: TNotifyEvent;
 

Methods

Private function GetName: TComponentName;

See Name.

Private function GetSubject: ISubject;

See Subject.

Private function GetObserverList: IObjectObserverList;
 
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 StopTalkingToAnyone;

StopTalkingToAnyone removes all subscribers to the current object. See StopsTalkingTo. StopTalkingToAnyone is called in Destroy.

Public procedure TalksTo(const Observer: TObserver);

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

     Subject.Subscribe(Observer.Observer);
     

See StopsTalkingTo, Subject, and Observer.

Public procedure StopsTalkingTo(const Observer: TObserver);

StopsTalkingTo removes Observer from the list of items to be notified when there is a change in this object. See TalksTo and StopTalkingToAnyone.

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

UpdateWithName assigns Name := AName.

Public function IsListeningTo(const AnotherObserver: TObserver): boolean;
 

Properties

Private property Observer: IObjectObserver read FObserver;

Observer is an interface implemented as a TObjectObserver which is used in handling subscriptions. See TalksTo. 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 TalksTo.

Public 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 GetObserverList;

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.

Public property OnNameChange: TNotifyEvent read FOnNameChange write FOnNameChange;
 
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.12.1 on 2013-05-13 15:42:04