ADTF
|
Use this template if you want to implement an ucom::ant::IObject based Interface and/or subclass an existing class that implements ucom::ant::IObject. More...
Public Member Functions | |
tResult | GetInterface (const char *i_strIID, void *&o_pInterface) override |
Query interfaces on an object. More... | |
tResult | GetInterface (const char *i_strIID, const void *&o_pInterface) const override |
Provides const correct interface querying. More... | |
void | Destroy () const override |
Destruct and deallocate instantiations of type IObject . More... | |
Public Member Functions inherited from IObject | |
ADTF_IID (IObject, "object.ant.ucom.adtf.iid") | |
Marks the IObject to be castable with the ucom_cast() More... | |
Additional Inherited Members | |
Protected Member Functions inherited from IObject | |
~IObject ()=default | |
Protected destructor --> Use implemented Destroy() instead of delete! | |
Use this template if you want to implement an ucom::ant::IObject based Interface and/or subclass an existing class that implements ucom::ant::IObject.
In fact you can pass any class as a template parameter and your new class will be publicly derived from it. All specified interfaces including those implemented and exposed by all base classes will be exposed via adtf::ucom::ant::IObject. Take a look at the following example:
If you want to expose a hierachy of interfaces make sure that you specify the parent interfaces before their children (compilation will fail with an appropriate message if the prerequisite is not met). For example:
Bases | The base classes and/or interfaces. |
|
inlineoverridevirtual |
Destruct and deallocate instantiations of type IObject
.
To safely deallocate arbitrary objects between binary boundaries, the usage of ordinary deallocation (e.g. delete
or free
) is strongly disadvised. Allocators and deallocator implementations might differ in different compiling modes which might result in undefined behavior if allocating an object in mode A (e.g. Release) and deallocating it in mode B (e.g. Debug). To ensure that an object is always allocated and deallocated on the same side of a DLL, method Destroy()
can be used. The usual implementation of Destroy()
just calls delete *this
as allocating usually works using new
. When calling IObject::Destroy()
on an instantiated object, the vtable of pure abstract interface IObject
points to the correct implementation of Destroy()
ensuring correct destructor calling and deallocation.
default_object
to use the standard implementation. Implements IObject.
|
inlineoverridevirtual |
Provides const correct interface querying.
Query interfaces on an object. The IObject::GetInterface method returns a pointer to a specified interface on an object to which a client currently holds an interface pointer. Due to the fact that this querying of interfaces is not at all type safe, the IObject::GetInterface methods reside inside the private section of the interface and can only be accessed by ucom_cast()
function template.
[in] | i_strIID | Identifier of the interface being requested. |
[out] | o_pInterface | Address of pointer variable that receives the interface pointer requested in idInterface. Upon successful return, *o_pInterface contains the requested interface pointer to the object. If the object does not expose the interface specified in i_strIID , i_pInterface is set to NULL. |
ERR_NOERROR | The interface identified by i_strIID was implemented and exposed by the implementation of *this. o_pInterface points to the queried interface. |
ERR_NO_INTERFACE | The requested interface is not exposed. o_pInterface==NULL |
ucom_cast()
function template Implements IObject.
Definition at line 389 of file object.h.
References interface_expose< Interfaces >::Get().
|
inlineoverridevirtual |
Query interfaces on an object.
The IObject::GetInterface method returns a pointer to a specified interface on an object to which a client currently holds an interface pointer. Due to the fact that this querying of interfaces is not at all type safe, the IObject::GetInterface methods reside inside the private section of the interface and can only be accessed by ucom_cast()
function template.
[in] | i_strIID | Identifier of the interface being requested. |
[out] | o_pInterface | Address of pointer variable that receives the interface pointer requested in idInterface. Upon successful return, *o_pInterface contains the requested interface pointer to the object. If the object does not expose the interface specified in i_strIID , i_pInterface is set to NULL. |
ERR_NOERROR | The interface identified by i_strIID was implemented and exposed by the implementation of *this. o_pInterface points to the queried interface. |
ERR_NO_INTERFACE | The requested interface is not exposed. o_pInterface==NULL |
ucom_cast()
function template Implements IObject.
Definition at line 384 of file object.h.
References interface_expose< Interfaces >::Get().