FPObserver Examples anywhere?

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

FPObserver Examples anywhere?

bsquared
Hello,

Does anyone know of any example code for the FPObserver interface?
Preferable with Collections.

Thank you.
--
Regards,
Brian

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: FPObserver Examples anywhere?

valeray12
This post has NOT been accepted by the mailing list yet.
How can I get a FPO box in the Philippines?
[url=http://www.barstoolmegastore.com]bar stool[/url]
Reply | Threaded
Open this post in threaded view
|

Re: FPObserver Examples anywhere?

Graeme Geldenhuys-3
In reply to this post by bsquared
On 2012-11-15 01:15, bsquared wrote:
> Hello,
>
> Does anyone know of any example code for the FPObserver interface?
> Preferable with Collections.

Sure, see attached. It's very basic, but shows the functionality.

NOTE:
  I used latest 2.7.1 compiler, where some base classes in the RTL
  support the IFPObserved interface.


And the demo output is as follows:

------------------------------------
$ ./fpobserver_demo
TStringList has changed [ooChange]
TStringList has changed [ooChange]
TStringList has changed [ooChange]
[ooFree] detected so we should detach ourselves
------------------------------------



This does raise some points of interest though.

 1) I would probably surface the IFPObserver methods to Public. Though
    there is good arguments to not do it either - thus you are forced
    to use correct interface usage... via Supports(), getting a
    interface pointer back, and using that interface pointer to make
    method calls.

 2) Even though I did two Add() calls and one Delete() call, TStringList
    reported the operation as simply ooChanged. Correct, but not very
    precise. After all, we also have ooAdd, ooDelete operation states
    we could work with.

 3) My personal preference is that the Observed automatically detaches
    Observers in the destructor. But this is just a personal preference
    in my own code.


Regards,
  - Graeme -


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

fpobserver_demo.pas (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: FPObserver Examples anywhere?

Sven Barth-2
Am 15.11.2012 14:29, schrieb Graeme Geldenhuys:
>   1) I would probably surface the IFPObserver methods to Public. Though
>      there is good arguments to not do it either - thus you are forced
>      to use correct interface usage... via Supports(), getting a
>      interface pointer back, and using that interface pointer to make
>      method calls.
Note: Although the IFPObserver and IFPObserved interfaces are defined as
Corba interfaces you should be able to use "YourInstance as IFPObserver"
instead of "Supports()".

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: FPObserver Examples anywhere?

bsquared
In reply to this post by Graeme Geldenhuys-3
On 11/15/2012 05:29 AM, Graeme Geldenhuys wrote:

> On 2012-11-15 01:15, bsquared wrote:
>> Hello,
>>
>> Does anyone know of any example code for the FPObserver interface?
>> Preferable with Collections.
>
> Sure, see attached. It's very basic, but shows the functionality.
>
> NOTE:
>    I used latest 2.7.1 compiler, where some base classes in the RTL
>    support the IFPObserved interface.
>
>
> And the demo output is as follows:
>
> ------------------------------------
> $ ./fpobserver_demo
> TStringList has changed [ooChange]
> TStringList has changed [ooChange]
> TStringList has changed [ooChange]
> [ooFree] detected so we should detach ourselves
> ------------------------------------
>
>
>
> This does raise some points of interest though.
>
>   1) I would probably surface the IFPObserver methods to Public. Though
>      there is good arguments to not do it either - thus you are forced
>      to use correct interface usage... via Supports(), getting a
>      interface pointer back, and using that interface pointer to make
>      method calls.
>
>   2) Even though I did two Add() calls and one Delete() call, TStringList
>      reported the operation as simply ooChanged. Correct, but not very
>      precise. After all, we also have ooAdd, ooDelete operation states
>      we could work with.
>
>   3) My personal preference is that the Observed automatically detaches
>      Observers in the destructor. But this is just a personal preference
>      in my own code.
>
>
> Regards,
>    - Graeme -
>
>
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>

Thank you for you example.

I have had no exposure to CORBA. Your example gave me just what I needed.

--
Regards,
Brian

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: FPObserver Examples anywhere?

bsquared
In reply to this post by Sven Barth-2
On 11/15/2012 08:39 AM, Sven Barth wrote:

> Am 15.11.2012 14:29, schrieb Graeme Geldenhuys:
>>   1) I would probably surface the IFPObserver methods to Public. Though
>>      there is good arguments to not do it either - thus you are forced
>>      to use correct interface usage... via Supports(), getting a
>>      interface pointer back, and using that interface pointer to make
>>      method calls.
> Note: Although the IFPObserver and IFPObserved interfaces are defined as
> Corba interfaces you should be able to use "YourInstance as IFPObserver"
> instead of "Supports()".
>
> Regards,
> Sven
> _______________________________________________
> fpc-pascal maillist  -
> [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
Is there an advantage?

--
Regards,
Brian

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: FPObserver Examples anywhere?

Graeme Geldenhuys-3
In reply to this post by Sven Barth-2
On 2012-11-15 16:39, Sven Barth wrote:
> Note: Although the IFPObserver and IFPObserved interfaces are defined as
> Corba interfaces you should be able to use "YourInstance as IFPObserver"
> instead of "Supports()".


Correct, but my preference is to use Supports() - it makes the code
easier to read and follow.


Regards,
  - Graeme -

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: FPObserver Examples anywhere?

Graeme Geldenhuys-3
In reply to this post by bsquared
On 2012-11-15 18:05, bsquared wrote:
>>
> Is there an advantage?


No difference, other than that I find Supports() easier to read.


G.



_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: FPObserver Examples anywhere?

Graeme Geldenhuys-3
In reply to this post by bsquared
On 2012-11-15 18:01, bsquared wrote:
>
> I have had no exposure to CORBA. Your example gave me just what I needed.

CORBA style interface are simply interfaces without reference counting -
so you are in control of when to free instances.

CORBA style interfaces (as seen in FPC) are far from a complete CORBA
ORB (Object Request Broker) implementation like the one included with
Delphi.

So ignore the name CORBA, and just think of it as COM interfaces without
reference counting. Oh, and CORBA interfaces don't descend from IUnknown
& IInterface.


Regards,
  - Graeme -


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: FPObserver Examples anywhere?

bsquared
On 11/15/2012 11:38 AM, Graeme Geldenhuys wrote:

> On 2012-11-15 18:01, bsquared wrote:
>>
>> I have had no exposure to CORBA. Your example gave me just what I needed.
>
> CORBA style interface are simply interfaces without reference counting -
> so you are in control of when to free instances.
>
> CORBA style interfaces (as seen in FPC) are far from a complete CORBA
> ORB (Object Request Broker) implementation like the one included with
> Delphi.
>
> So ignore the name CORBA, and just think of it as COM interfaces without
> reference counting. Oh, and CORBA interfaces don't descend from IUnknown
> & IInterface.
>
>
> Regards,
>    - Graeme -
>
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>

Thanks again.
--
Regards,
Brian

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal