0
votes
Vote UpVote

Delphi: a pattern for a generic factory, this one for components, but can be uses for anything having a base class like a TThread descendant.

The Wiert Corner – Generics and constraints in Delphi as still a bit of pain. A while ago, I needed a factory for threads. It was more convoluted than I meant it to be, so I had a short chat with Stefan Glienke. He came up with an example similar to the one below. I tore it apart so you can on each line see what the compiler dislikes. This fails, but was kind of how I wanted it to be: type TFactory = record class function Manufacture<T: TBaseClass, constructor(parameter definitions): T; end; class function Manufacture<T: TBaseClass, constructor(parameter definitions): T; begin Result := ...
Favorite? Off-Topic? jpluimers @ 2018-05-16 07:04

Statistics

Visits: 159
Votes: 0
Favorites: 0
Off-Topic: 0

Visits by Source

User Actions

Users who voted for this posting

Subscribe:
Contact us to advertise on DelphiFeeds.com

Community Links

Torry Firebird News

Sponsor

 
Please login or register to use this functionality.
(click on this box to dismiss)