I'm storing in stream classes fields values (each class has SaveToStream/LoadFrom strem methods). Now for example if I need load from file these classes to object I'm doing:
Delphi-Quellcode:
case AType of
0: TFirstClass.Create.LoadFromStream;
1: TAnotherClass.Create.LoadFromStream;
// ........
end;
This was good (but yes - lame) when was small set of classes. Now I have many ones and this method is also annoying when need to update.
Is possible map number to class type:
Delphi-Quellcode:
function GetType(AType: Int32): TBaseClass;
begin
// ?????????????????
end;
and do
GetType(AType).Create.LoadFromStream
;