I made a custom TObjectList descendant designed to hold subclasses of a base object class. It looks something like this:
interface
TMyDataList
Just a quick update to an old question..
You don't need the constructor constraint and can also do this on object's with parameters by using RTTI like this (using RTTI or System.RTTI with XE2)
constructor TMyDataList.Create;
var
ctx: TRttiContext;
begin
inherited Create(true);
self.Add(
ctx.
GetType(TClass(T)).
GetMethod('create').
Invoke(TClass(T),[]).AsType
);
end;
If you have parameters, just add them like this
constructor TMyDataList.Create;
var
ctx: TRttiContext;
begin
inherited Create(true);
self.Add(
ctx.
GetType(TClass(T)).
GetMethod('create').
Invoke(TClass(T),[TValue.From('Test'),TValue.From(42)]).AsType
);
end;