[fpc-devel] Suggestion: reference counted objects

Boian Mitov mitov at mitov.com
Sat Sep 20 19:27:40 CEST 2014


I would propose either a virtual method or attribute that enables disables 
this.
Indeed in our code we have adopted a pattern that implements both:

TMyObject = class
public
  function HasSomeFunctionality() : Boolean; virtual;

end;

function TMyObject.HasSomeFunctionality() : Boolean;
begin
  Result TypeInfo().HasAttribute( SomeFunctionalityAttribute );
end;

This way you can override the virtual method or just change/supress the 
attribute (In Mitov.TypeInfo advanced RTTI we have added the option to 
suppress attributes etc. ;-) )
Or the attribute can be boolean and use it as On/Off .

With best regards,
Boian Mitov

-------------------------------------------------------
Mitov Software
www.mitov.com
-------------------------------------------------------
-----Original Message----- 
From: Ewald
Sent: Saturday, September 20, 2014 5:15 AM
To: FPC developers' list
Subject: Re: [fpc-devel] Suggestion: reference counted objects

On 09/20/2014 01:42 PM, Sven Barth wrote:
What would be handy is a seperate root class that is always refcounted,
something like TRefcountedObject or something. On the other hand some
directive that makes this class refcounted would also be a good solution
IMO (something that works for refcounting in the same way as $M does for
RTTI).

Just my 5 cents.

-- 
Ewald


_______________________________________________
fpc-devel maillist  -  fpc-devel at lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel 




More information about the fpc-devel mailing list