IFactory
模块: oapy._oa._common
导入: from oapy._oa import _common
概览
IFactory 在 oapy 中可用,可通过 _common 模块访问。
本页汇总 IFactory 当前在 oapy 中可用的 Python 接口。
详细说明
This is the abstract factory interface。 This factory is implemented by the plug-in and is used to create instances of interface objects as needed。 There is generally one implementation of the IFactory interface for each type of component。
方法总览
| 状态 | Python 调用 |
|---|---|
| ✅ | obj.createInstance(reserved, id, iPtr) |
方法说明
obj.createInstance(reserved, id, iPtr)
绑定状态: 已绑定
Python 调用: obj.createInstance(reserved, id, iPtr)
This function creates an instance of the component that this factory is implemented to manage。 Note that if there is any problem creating the component, or querying the requested interface from it, iPtr is set to NULL, and this function returns one of the values from IBase::Status to identify the problem。 IBase::cOK is returned if no problems are encountered。 由 Factory 实现。
参数
reserved: This parameter is reserved for advanced usage of components。 It represents the "outer object" in an aggregation relationship。 For simple, non-aggregated components, this parameter must be set to NULL。id: This is a reference to the class id of the required interface。 Note that if the component does not implement this interface, the factory deletes the instance it created and sets iPtr to NULL。 If the particular interface that the component implements is not known (for instance, it may be another version of an interface, but both may not be available) the best strategy is to create the component and request the IBase interface, which is guartanteed to be implemented。 Then, queryInterface can be used to determine which particular version of the interface is implemented。*iPtr: This parameter is set to a pointer to the requested interface from the new component, or NULL if there was a problem creating the component, or if the required interface is not implemented by this compoinent。
Python 示例
from oapy._oa import _common
# assume obj is a IFactory
obj.createInstance(reserved, id, iPtr)