[UOPL-Architect] Maybe Helper Classes would help.
Status: Planning
Brought to you by:
bsstmiller
|
From: Richard B W. <rb...@us...> - 2004-12-24 13:18:10
|
There is a new language feature in Delphi2005 for Win32 that might be useful for some of the things we would like to do with UOPL: Helper Classes. One thing you can do with them is replace an existing procedure of a class with a new procedure from a different class that is not the descendent of the first class. Although helper classes are only documented for Delphi for .NET, they work in Delphi for Win32 too. See http://www.aspfree.com/c/a/.NET/The-Delphi-Language-Part-2/9/ for more information. Here is an example. unit Unit5; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TFoo = class strict protected procedure AProc; virtual; end; TFooDescendent = class(TFoo) procedure AProc; override; end; TFooHelper = class helper for TFoo procedure AProc; end; type TForm5 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form5: TForm5; implementation {$R *.dfm} { TFoo } procedure TFoo.AProc; begin ShowMessage('TFoo'); end; { TFooHelper } procedure TFooHelper.AProc; begin ShowMessage('TFooHelper'); end; { TFooDescendent } procedure TFooDescendent.AProc; begin inherited; ShowMessage('TFooDescendent'); end; procedure TForm5.Button1Click(Sender: TObject); var Foo: TFoo; FooDescendent: TFooDescendent; begin FooDescendent := TFooDescendent.Create; try // TFooHelper.AProc and TFooDescendent.AProc get called here // but not TFoo.AProc! FooDescendent.AProc; Foo := FooDescendent; // Only TFooHelper.AProc gets called here. :-( Foo.AProc; finally FooDescendent.Free; end; end; end. Richard B. Winston rb...@us... http://water.usgs.gov/nrp/gwsoftware/ 703-648-5988 on Fridays: 301 474-2762 |