[fpc-devel] Tests of observer feature [was: Considerations about observer]

luiz americo pereira camara luizmed at oi.com.br
Fri Nov 30 03:03:47 CET 2012


2012/11/29 luiz americo pereira camara <luizmed at oi.com.br>:

>
> There's a more concrete example about the duplicate typecast.
>
> I'm developing a model manager that would be responsible to easily
> create LCL forms/frames, html forms, LazReport reports etc with the
> same set of data/models
>
> Each project has a TModels collection with a TModel item
> Each TMode item has a TFields collection with a TField item
> Each TField has a unique Id managed per project
> Currently to set the id of new Fields i have a circular reference
> TField <> Project
> My idea is to isolate TModel/TField to be independent of TProject
> I can add a intermediate class to connect each other
> But i could also takes advantage of Observer so i could observe the
> Fields collection of each TModel to update the id when is added
> The idea is add a FieldsObserver property to TModels and attach it to
> each TModel
>
> It can be done as today?. Sure. My concerns are
>
> - I cannot define FieldsObserver as IFPObserver (the reasons why do i
> prefer as it are above)
> - Using FieldsObserver as TObject each time i attach/dettach from a
> TFields there will be a type cast that i know before hand is not
> necessary and could avoid.

Attached is the classes as is today.

I'll try to get rid of circular dependency from TProject using the
observer pattern. I 'll post the result later

Luiz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: datamodelclasses.pas
Type: application/octet-stream
Size: 11518 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20121129/30aad164/attachment.obj>


More information about the fpc-devel mailing list