是否存在像TInterfacedObject这样的非引用计数基类?

Hei*_*cht 16 delphi interface reference-counting delphi-xe

我需要一个基类,TInterfacedObject但没有引用计数(所以一种TNonRefCountedInterfacedObject).

这实际上是第n次我需要这样一个课程,不知何故,我总是一次又一次地写作(阅读:复制和粘贴)我自己.我无法相信我没有可以使用的"官方"基类.

在RTL实现的某个地方是否存在基类,IInterface但没有引用计数,我可以从中派生我的类?

Erw*_*win 16

在Generics.Defaults单元中,定义了一个类TSingletonImplementation.适用于Delphi 2009及更高版本.

  // A non-reference-counted IInterface implementation.
  TSingletonImplementation = class(TObject, IInterface)
  protected
    function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall;
    function _AddRef: Integer; stdcall;
    function _Release: Integer; stdcall;
  end;
Run Code Online (Sandbox Code Playgroud)