[fpc-pascal] Problem accessing Class Method with abstraction
Andrew Brunner
andrew.t.brunner at gmail.com
Sun Oct 17 04:54:40 CEST 2010
I've got a class factory problem I'm trying to resolve and it appears
I'm at a point where it's probably better to ask for help.
TCoreObjects=class;
TCoreObject=Class (TPersistent)
protected
class procedure VerifyIDs(var Module:TDBMSModule); Virtual; abstract;
end;
TAdminCore=Class(TCoreObject)
protected
class procedure VerifiyIDs(var Module:TDBMSModule); override;
end;
<SNIP>
procedure VerifyIDs(Var Module:TDBMSModule);
var
iLcv:integer;
ItemP:PCoreObjectItem; // Just record storing classname to load and
(each core object implment is loaded just not detailed here for
simplicity)
coGeneric:TPersistentClass;
coItem:TCoreObject;
begin
for iLcv:=0 to High(CoreObjectItems) do begin
ItemP:=CoreObjectItems[iLcv];
coGeneric:=GetClass(ItemP^.ClassName);
if (coGeneric<>nil) and coGeneric.InheritsFrom(TCoreObject) then begin
coItem:=coGeneric as TCoreObject << COMPILER ERROR :-(
TPersistentClass(coItem):=coGeneric; << Compiles but get Runtime Error
coItem.VerifyIDs(Module); < CRASH @ RUNTIME
end;
end;
end;
How can I get each class's implement of VerifyIDs to get called as
each one is different but yet single.
More information about the fpc-pascal
mailing list