[Lazarus] Controlling access to a method
Mattias Gaertner
nc-gaertnma at netcologne.de
Wed Jan 30 15:11:42 CET 2013
On Wed, 30 Jan 2013 11:18:08 +0000
Mark Morgan Lloyd <markMLl.lazarus at telemetry.co.uk> wrote:
> Given a fragment of code like this:
>
> type
> TDbConfigFrame = class(TFrame)
> ..
> public
> { public declarations }
> property DbInit: TDbConfigInit write fdbInit;
> end;
>
> is there any way of enforcing a rule that DbInit can only be written by
> (for example) a descendant of TForm or TNotebook? Or only being writable
> by e.g. the OnCreate() method of certain designated form instances?
Why not add a method
procedure TDbConfigFrame.SetDBInit(Setter: TComponent;
NewInit: TDbConfigInit);
begin
if not ((Setter is TForm) or (Setter is TNoteBook)) then
raise Exception.Create('not allowed');
fdbinit:=NewInit;
end;
Mattias
More information about the Lazarus
mailing list