The application should know the base of a class to use it. The interface, protocol, specification, you name it. The particular package gives a certain specialized implementatino of it.
So the overall structure, based on BPL and conventional objects, should be the one that you can observe in VCL itself.
Base.BPL - contains TBaseClass
and TList<TBaseClass>
of implementations provided by plugins. It also contains all virtual methods and properties needed for main program to use it. It is convenient to have
class constructor TBaseClass.CreateClass;
begin
MyList := TList<TBaseClass>.Create;
end;
class destructor TBaseClass.DestroyClass;
begin
FreeAndNil(MyList);
end;
class procedure TBaseClass.RegisterClass;
Begin
MyList.Add(Self);
end;
class procedure TBaseClass.UnRegisterClass;
Begin
MyList.Remove(Self);
end;
App.Exe would list Base.BPL among its runtime packages (in project options) and use Base.BPL as a "meeting point" with plugins.
Plugin.BPL would list Base.Bpl as required runtime package and use it as rendezvous place too.
TMyClass1 = class (TBaseClass);
...
initialization
TMyClass1.RegisterClass;
finalization
TMyClass1.UnRegisterClass;
end.
My TCustOrder has property named "Client:TObject" how can i access this property from the host application.
type (** Base.BPL **)
TBaseClass = class ...
protected function GetClient: TObject; virtual; abstract;
public property Client read GetClient;
...
end;
type (** Plugin.BPL **)
TMyClass1 = class(TBaseClass) ...
protected function GetClient: TObject; override;
...
end;
Note, at least Delphi XE2 tends to destroy string array constants when unloading dynamic packages. Dunno if it holds for D2010. In XE4 it was fixed. So "dragons may be here". In modern Delphi there are a lto of bugs in RTL/VCL, be ready to debug them.