#[cape_smart_pointer]Expand description
The cape_smart_pointer macro generates the necessary code to implement a COBIA smart pointer.
It exercises the ICapeInterface implementation, provides error handling, handles reference counting and handles QueryInterface.
It is expected that the interface data member is named ‘interface’. Also the wrapper provides
fn from_interface_pointer(interface: *mut Interface) -> Self
where Interface is the interface type that the wrapper implements; from_interface_pointer should increase the reference count of the object. A second construction is needed that does not increase the reference count, to construct the smart pointer from a return value that already has its reference count adjusted (e.g from query_interface or any function that returns an interface pointer):
fn attach(interface: *mut Interface) -> Self
The contained interface pointer is released upon Drop, except when the smart pointer is detached. The smart pointer can be cloned, which increases the reference count of the contained interface pointer.
This macro is used for a wrapper class implementation that refer to a COBIA object. This macro will generate the necessary code to implement the CapeSmartPointer, Drop (=release) and Clone (=addReference) traits.
Code that uses the cape_smart_pointer macro is typically provided (CobiaCollectionBase, CobiaIdentification, …) or generated from type information (see e.g. the cape_open_1_2 module).
The attribute passed to the interface is the interface ID. The interface type is derived from the ‘interface’ member, which must be a *mut of the interface type.