TCppInterfacedObject - C++ Build

2020-05-16  本文已影响0人  玄坴

C++ Builder 参考手册 ➙ System ➙ TCppInterfacedObject


System::TCppInterfacedObject 是基于 TInterfacedObject 派生出来的类模板,用于实现 IInterface (IUnknown) 接口,在使用不支持 lambda 表达式的编译器或不想用 lambda 表达式的时候,采用这个模板来实现 Delphi 的匿名函数


一. System::TCppInterfacedObject 简介

System::TCppInterfacedObject 是

template <typename INTF1, typename INTF2=IUnknown, typename INTF3=IInterface>
class TCppInterfacedObject: public TInterfacedObject,
                            public INTF1, public INTF2, public INTF3
{
protected:
    typedef TCppInterfacedObject<INTF1, INTF2, INTF3> _COM_CLASS;
public:
    ULONG   __stdcall AddRef()  { return TInterfacedObject::_AddRef();  }
    ULONG   __stdcall Release() { return TInterfacedObject::_Release(); }
    HRESULT __stdcall QueryInterface(REFIID iid, void** p) { return TInterfacedObject::QueryInterface(iid, p); }
};

二. System::TCppInterfacedObject 成员

1. System::TCppInterfacedObject 属性

属性 类型 说明
TInterfacedObject:: System::TInterfacedObject 继承过来的
public:    
RefCount int 引用计数

2. System::TCppInterfacedObject 方法

成员函数 说明
public:  
AddRef 增加引用计数
QueryInterface 返回当前组件所支持的 COM 接口的引用
Release 减少引用计数 / 销毁对象
TInterfacedObject:: System::TInterfacedObject 继承过来的
public: System::TInterfacedObject 继承过来的
_AddRef 增加引用计数
AfterConstruction 在构造函数执行结束时调用
BeforeDestruction 在析构函数执行之前时调用
NewInstance 给实例分配内存,并且返回新的实例的地址
operator _di_IInterface 类型转换操作符,转为 _di_IInterface 类型
_Release 减少引用计数 / 销毁对象
TObject:: System::TObject 继承过来的
public: System::TObject 继承过来的
ClassInfo 返回运行时类型信息表 (RTTI table)
ClassName 获取类名,不包含命名空间的类名字符串
ClassNameIs 判断类名是否为参数指定的字符串
ClassParent 返回父类的类型信息
ClassType 返回类的类型信息
CleanupInstance 清除长字符串、Variants、接口变量等
DefaultHandler 默认的消息处理
Dispatch 处理消息的函数
DisposeOf 强制销毁对象
Equals 比较当前对象和 Obj 对象是否相同
FieldAddress 通过成员名称返回成员的地址
Free 销毁对象 (Delphi)
FreeInstance 释放 NewInstance 分配的内存
GetHashCode 返回对象的 hash 值
GetInterface 获取指定的接口
GetInterfaceEntry 获取接口项目
GetInterfaceTable 获取接口表
InheritsFrom 当前对象的类是否从 AClass 继承过来的
InitInstance 初始化成员,给他们清零
InstanceSize 返回给实例数据分配内存需要多少字节数
MethodAddress 通过名称返方法的地址
MethodName 通过方法的地址返回名称
QualifiedClassName 返回包含命名空间的类名
SafeCallException 处理异常的函数
ToString 转为字符串
UnitName 返回类所在的命名空间
UnitScope 返回类所在的命名空间

3. System::TCppInterfacedObject 类型成员

类型 说明
protected:  
_COM_CLASS 就是这个模板类型本身带上模板参数的类型

4. System::TCppInterfacedObject 数据成员

数据 类型 说明
TInterfacedObject:: System::TInterfacedObject 继承过来的
protected: System::TInterfacedObject 继承过来的
FRefCount int 用于保存引用计数

相关:


C++ Builder 参考手册 ➙ System ➙ TCppInterfacedObject

上一篇 下一篇

猜你喜欢

热点阅读