Recent

Author Topic: How to communicate between nested classes?  (Read 9187 times)

cdbc

  • Hero Member
  • *****
  • Posts: 1025
    • http://www.cdbc.dk
Re: How to communicate between nested classes?
« Reply #15 on: July 22, 2014, 04:58:16 pm »
 8-) Hi there.
@ Mike.Cornflake:  Here's an implementation of the observer pattern for you  :D You can expand and modify as you please...

Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: How to communicate between nested classes?
« Reply #16 on: July 22, 2014, 05:52:41 pm »
You can expand and modify as you please...

So I modified this excellent example with a few changes to use Corba interfaces (which I usually prefer). The programmer then has complete control over when and if constructs are freed, rather than relying on compiler-generated reference-counting code which does this behind your back at unknown moments.
Attached is an alternative implementation in case it is useful.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: How to communicate between nested classes?
« Reply #17 on: July 22, 2014, 06:09:50 pm »
So I modified this excellent example with a few changes to use Corba interfaces (which I usually prefer). The programmer then has complete control over when and if constructs are freed, rather than relying on compiler-generated reference-counting code which does this behind your back at unknown moments.

Refcounting is generally very defined when what happens, and how long it will approx take. It is what sets it apart from other GC techniques

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: How to comunicate between nested classes?
« Reply #18 on: July 22, 2014, 07:07:43 pm »
Code: [Select]
TTopClass = class (TObject)
   Nested1: TNested1;
   procedure MyProc;
   MyVar: integer;
end; 
 

You should use a field instead of a variable and put it here:

Code: [Select]
TTopClass = class (TObject)
   MyVar: integer;
   Nested1: TNested1;
   procedure MyProc;
end; 
 

 

TinyPortal © 2005-2018