Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-03

Published properties of classtypes

5 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ales Katona

If you make a "class of something" published, it will compile, but the property won't show in the OI. I'm not sure if it's supposed to work so I'm asking here.. Vincent also mentioned "TTypeKind support tkClass" :)

So.. should it be possible to use "class of " as published properties in the OI?

Ales

Reply by email

Michael Van Canneyt
to Ales Katona
Ales Katona wrote 6 lines
If you make a "class of something" published, it will compile, but the property won't show in the OI. I'm not sure if it's supposed to work so I'm asking here.. Vincent also mentioned "TTypeKind support tkClass" :) So.. should it be possible to use "class of " as published properties in the OI?

No, because you cannot enter a value anyway.
How will you resolve a text to a class pointer ?

Michael.

Reply by email

Inoussa OUEDRAOGO
to Michael Van Canneyt

2008/3/3, Michael Van Canneyt :

Show quoted text 14 lines
On Mon, 3 Mar 2008, Ales Katona wrote: > If you make a "class of something" published, it will compile, but the > property won't show in the OI. I'm not sure if it's supposed to work so > I'm asking here.. Vincent also mentioned "TTypeKind support tkClass" :) > > So.. should it be possible to use "class of " as published properties in > the OI? No, because you cannot enter a value anyway. How will you resolve a text to a class pointer ?

If the class is registered ( using RegisterClass() ), it can be found with FindClass().

<code unit="classes">
  procedure RegisterClass(AClass: TPersistentClass);
  function FindClass(const AClassName: string): TPersistentClass;
</code>
Inoussa O.

Reply by email

Michael Van Canneyt
to Inoussa OUEDRAOGO
Inoussa OUEDRAOGO wrote 23 lines
2008/3/3, Michael Van Canneyt : > > > On Mon, 3 Mar 2008, Ales Katona wrote: > > > If you make a "class of something" published, it will compile, but the > > property won't show in the OI. I'm not sure if it's supposed to work so > > I'm asking here.. Vincent also mentioned "TTypeKind support tkClass" :) > > > > So.. should it be possible to use "class of " as published properties in > > the OI? > > > No, because you cannot enter a value anyway. > How will you resolve a text to a class pointer ? If the class is registered ( using RegisterClass() ), it can be found with FindClass(). <code unit="classes"> procedure RegisterClass(AClass: TPersistentClass); function FindClass(const AClassName: string): TPersistentClass; </code>

You will find that this is almost never used. None of the classes in the FCL/LCL is registered. They need not be registered, only exceptional cases must be registered using this callback. That rather limits the use IMHO ?

Michael.

Reply by email

Inoussa OUEDRAOGO
to Michael Van Canneyt

2008/3/3, Michael Van Canneyt :

Show quoted text 32 lines
On Mon, 3 Mar 2008, Inoussa OUEDRAOGO wrote: > 2008/3/3, Michael Van Canneyt : > > > > > > On Mon, 3 Mar 2008, Ales Katona wrote: > > > > > If you make a "class of something" published, it will compile, but the > > > property won't show in the OI. I'm not sure if it's supposed to work so > > > I'm asking here.. Vincent also mentioned "TTypeKind support tkClass" :) > > > > > > So.. should it be possible to use "class of " as published properties in > > > the OI? > > > > > > No, because you cannot enter a value anyway. > > How will you resolve a text to a class pointer ? > > If the class is registered ( using RegisterClass() ), it can be found > with FindClass(). > > <code unit="classes"> > procedure RegisterClass(AClass: TPersistentClass); > function FindClass(const AClassName: string): TPersistentClass; > </code> You will find that this is almost never used. None of the classes in the FCL/LCL is registered. They need not be registered, only exceptional cases must be registered using this callback. That rather limits the use IMHO ?

It can be used to "virtualize" a class behavior as in the code below: The worker object
receive some work items and based on his property HandlerClass, it creates a handler instance
that process the items. Their could be some registered hanlder classes for specific needs.
And it will be nice to be able to configure the worker component at design through the OI(
the editor could be a combobox with its items filed by the registered class that inherits
from TItemHandler ).

<code>
TItemHandler = class(TPersistent)
public
  procedure ProcessData(const AData); virtual; abstract;
end;
TItemHandlerClass = class of TItemHandler;
TWorker = class(TComponent)
private
...
  FHandlerClass : TItemHandlerClass;
  FHandler : TItemHandler;
...
published
  property HandlerClass : TItemHandlerClass read FHandlerClass write
SetHandlerClass;
end;
TAsyncHandler = class(TItemHandler)
public
  procedure ProcessData(const AData); virtual; override;
end;
TSynchroneHandler = class(TItemHandler)
public
  procedure ProcessData(const AData); virtual; override;
end;
</code>
Inoussa O.

Reply by email