[fpc-pascal] IFPObserved
Michael Van Canneyt
michael at freepascal.org
Wed Sep 11 08:50:01 CEST 2013
On Wed, 11 Sep 2013, Xiangrong Fang wrote:
> Hi All,
>
> Where can I find detailed documentation on IFPObserved? This page only defines the interface but not telling about the purpose of this interface:
>
> http://www.freepascal.org/docs-html/rtl/classes/ifpobserved.html
>
> My questions are:
>
> - what is this interface for?
There are 2 interfaces: IFPObserved and IFPObserver.
Together they form the observer pattern that can be used to implement the mediator pattern.
Basically, if an object wants to notify other observers that it 'has changed', it implements the IFPObserved interface.
Since TStrings is a prime candidate for this, IFPObserved has been implemented in TPersistent.
This means that any component can act as an observed object. It is up to the component implementation to decide which changes must be communicated.
An object that wishes to be notified by other objects that they have changed, implements the IFPObserver pattern.
It must implement 1 method which will get called whenever an object that it is observing, changes.
Both interfaces are CORBA interfaces, so they do not have the burden of reference counting.
> - any example on when and why to use it?
The fpobserver.pp unit contains an implementation of a mediator and a mediator registry.
This could be used for example to implement the Live Bindings of Embarcadero in a rather trivial manner.
> - Where can I find documentation that contains explanation on the above 2 questions, so that I can get a "big picture"? For example, if there are any similar interfaces that form the foundation of FCL or LCL?
I have a complete CD-Cover design program somewhere, which is written with this technology;
I also have somewhere some articles that discuss the design, I will see about publishing
them on-line somewhere ASAP. I can send you a copy if you want.
Michael.
More information about the fpc-pascal
mailing list