Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2013-03

Overriding or reimplementing a property

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mark Morgan Lloyd

Given something like

implementation
var     DBConnectionNearby: TSQLConnection= nil;
..
case MainForm.NearbyKind of
   dbkFirebird: DBConnectionNearby := TIBConnection.Create(nil);
   dbkPostgres: DBConnectionNearby := TPQConnection.Create(nil);

is there an elegant way of overriding the Connected property to point to code that can e.g. check that all prerequisite libraries are available before trying to activate the object?

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Marco van de Voort
to Mark Morgan Lloyd

In our previous episode, Mark Morgan Lloyd said:

Show quoted text 14 lines
Given something like implementation var DBConnectionNearby: TSQLConnection= nil; .. case MainForm.NearbyKind of dbkFirebird: DBConnectionNearby := TIBConnection.Create(nil); dbkPostgres: DBConnectionNearby := TPQConnection.Create(nil); is there an elegant way of overriding the Connected property to point to code that can e.g. check that all prerequisite libraries are available before trying to activate the object?

Check the prequisite libraries yourself, and then if found, initialize the corresponding unit yourself:

e.g. in the case of postgres3dyn using

Function InitialisePostgres3(Const libpath : ansistring) : integer;

Reply by email

Mark Morgan Lloyd
to Marco van de Voort
Marco van de Voort wrote 22 lines
In our previous episode, Mark Morgan Lloyd said: > Given something like > > implementation > > var DBConnectionNearby: TSQLConnection= nil; > > .. > case MainForm.NearbyKind of > dbkFirebird: DBConnectionNearby := TIBConnection.Create(nil); > dbkPostgres: DBConnectionNearby := TPQConnection.Create(nil); > > is there an elegant way of overriding the Connected property to point to > code that can e.g. check that all prerequisite libraries are available > before trying to activate the object? Check the prequisite libraries yourself, and then if found, initialize the corresponding unit yourself: e.g. in the case of postgres3dyn using Function InitialisePostgres3(Const libpath : ansistring) : integer;

I'm doing that. What I'm checking is that I'm not overlooking some way of declaring/implementing DBConnectionNearby, which can be either a TIBConnection or a TPQConnection, with an extension to the Connected property. I suppose that in effect it would be some variant of multiple inheritance.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email