On Thu, 29 Nov 2012, Graeme Geldenhuys wrote:

Hi Luiz,

First off, thanks for take the trouble it creating test projects.


On 2012-11-29 02:59, luiz americo pereira camara wrote:

Test1
As is today, if you have a reference to a IFPObserver is not possible
to use it to attach to, e.g., child objects. This occurs because AFAIK
you can't get a TObject from a interface reference.


OK, there are quite a few things I consider wrong with your Test1
application.

1) Nothing stops Michael from extending the IPFObserver interface to
   include a GetObject function that returns a TObject reference of
   the observer.
   I have seen many such cases in the wild. Not sure if I agree
   with it, but that is another story.

2) What exactly are you observing in Test1? What are you trying to
   accomplish?
   TMyParentView is a TObject. Adding children to the Children property
   doesn't notify the observer about anything.
   ... now if the Observer property is holding reference to something
   that should observer each of the Children, well, then that is very
   easy to accomplish too. Simply changes the Observer property to
   a TObject instance.

3) Something Michael should fix. TFPObjectList doesn't support
   IPFObserver. TObjectList does though. I guess many of the list
   classes in the Contnrs unit should be double checked.

No. This is left out on purpose.

If you want observer support, you need TObjectList and TList.

The primary reason of existence for TFPList and TFPObjectList is speed and
minimal overhead. TList and it's observer/notification capabilities introduce a serious speed penalty.

For instance when doing a Clear, all items are removed one by one as opposed to just de-allocating the array used to hold them.

Michael.
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to