I'm playing around with the OmniThread lib, adding some functionality to the pipeline class.
I now want to add some attributes, but for this to work I need the RTTI to be generated.
It turns out that RTTI is disabled for all of Otl, by using the {$TYPEINFO OFF}
directive.
Setting {$TYPEINFO ON}
globally breaks the library, so that's not an option.
I'm trying to selectively enable RTTI for my own classes.
{$M+}
{$RTTI EXPLICIT METHODS([vcPrivate,vcProtected,vcPublic, vcPublished]) PROPERTIES(([vcPrivate,vcProtected,vcPublic, vcPublished])) FIELDS(([vcPrivate,vcProtected,vcPublic, vcPublished]))}
[Capabilities([SplitInput])]
TOmniMultiPipelineSplitter = class(TOmniMultiPipelineStage, IOmniMultiSplitter)
public
/// <summary>
/// Creates a splitter with 1 input and 2 outputs.
/// Additional outputs can be added later if required.
/// </summary>
constructor Create; overload;
constructor Create(const Input: IOmniBlockingCollection); overload;
constructor Create(PrevStage: TGUID; PrevQueue: integer); overload;
function AddOutputQueue: IOmniBlockingCollection;
end;
{$M-}
But no matter what I do the RTTI does not get genererated.
Here's the code that I'm using to get hold of the RTTI for my class:
function FindAllFlavoursOf(basetype: TClass): TFlavours;
var
ctx: TRttiContext;
lType: TRttiType;
begin
Result:= TList<TClass>.Create;
ctx:= TRttiContext.Create;
for lType in ctx.GetTypes do
if (lType is TRttiInstanceType) and
(TRttiInstanceType(lType).MetaclassType.InheritsFrom(basetype)) then begin
Result.Add(TRttiInstanceType(lType).MetaclassType);
end;
end;
This code finds nothing for classes derived from TOmniMultiPipelineStage
, however it does find something for classes derived from TInterfacedObject
.
All classes with generic parameters seem to be included.
How do I get Delphi to put RTTI in my classes?
-- Yes, I did enable RTTI in the project settings:
-- Yes the classes are used in my code. I run a pipeline that uses these classes when I press the Go button.