ADTF
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
object< Bases >

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...

#include <object.h>

Inheritance diagram for object< Bases >:
[legend]

Public Member Functions

tResult GetInterface (const char *i_strIID, void *&o_pInterface) override
 Query interfaces on an object.
 
tResult GetInterface (const char *i_strIID, const void *&o_pInterface) const override
 Provides const correct interface querying.
 
void Destroy () const override
 Switch from non-virtual destructor to virtual destructor.
 
- Public Member Functions inherited from IObject
 ADTF_IID (IObject, "object.ant.ucom.adtf.iid")
 Marks the IObject to be castable with the ucom_cast()
 

Additional Inherited Members

- Protected Member Functions inherited from IObject
 ~IObject ()=default
 Protected destructor --> Only the final implementation can be destroyed!
 

Detailed Description

template<typename ... Bases>
class adtf::ucom::catwo::object< Bases >

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:

class Interface1: public ucom::IObject
{
public:
ADTF_IID(Interface1, "Interface1");
};
class Interface2: public ucom::IObject
{
public:
ADTF_IID(Interface2, "Interface2");
};
class Interface3: public ucom::IObject
{
public:
ADTF_IID(Interface3, "Interface3");
};
class cImplementsOneTwo: public ucom::object<Interface1, Interface2>
{
//implement methods from Interface1 and Interface2 here
};
class cImplementsOneTwoThree: public ucom::object<cImplementsOneTwo, Interface3>
{
//implement methods from Interface3 here
};
#define ADTF_IID(_interface, _striid)
Common macro to enable correct treatment of interface classes by the adtf::ucom::ucom_cast<>
Definition adtf_iid.h:19
Use this template if you want to implement an ucom::ant::IObject based Interface and/or subclass an e...
Definition object.h:397
ant::IObject IObject
Alias always bringing the latest version of ant::IObject into scope.

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:

class IParent: public ucom::IObject
{
public:
ADTF_IID(IParent, "Parent");
};
class IChild1: public IParent
{
public:
ADTF_IID(IChild1, "Child1");
};
class IChild2: public IChild1
{
public:
ADTF_IID(IChild2, "Child2");
};
class cImplementation: public ucom::object<IParent, IChild1, IChild2>
{
//implement methods from IChild2 here (including those of IParent and IChild1)
};
Template Parameters
BasesThe base classes and/or interfaces.

Definition at line 395 of file object.h.

Member Function Documentation

◆ Destroy()

template<typename ... Bases>
void Destroy ( ) const
inlineoverridevirtual

Switch from non-virtual destructor to virtual destructor.

Implements IObject.

Definition at line 417 of file object.h.

◆ GetInterface() [1/2]

template<typename ... Bases>
tResult GetInterface ( const char * i_strIID,
const void *& o_pInterface ) const
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.

Parameters
[in]i_strIIDIdentifier of the interface being requested.
[out]o_pInterfaceAddress 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.
Returns
Standard error.
Return values
ERR_NOERRORThe interface identified by i_strIID was implemented and exposed by the implementation of *this. o_pInterface points to the queried interface.
ERR_NO_INTERFACEThe requested interface is not exposed. o_pInterface==NULL
See also
ucom_cast() function template
The ucom_cast<> in depth explanation

Implements IObject.

Definition at line 406 of file object.h.

◆ GetInterface() [2/2]

template<typename ... Bases>
tResult GetInterface ( const char * i_strIID,
void *& o_pInterface )
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.

Parameters
[in]i_strIIDIdentifier of the interface being requested.
[out]o_pInterfaceAddress 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.
Returns
Standard error.
Return values
ERR_NOERRORThe interface identified by i_strIID was implemented and exposed by the implementation of *this. o_pInterface points to the queried interface.
ERR_NO_INTERFACEThe requested interface is not exposed. o_pInterface==NULL
See also
ucom_cast() function template
The ucom_cast<> in depth explanation

Implements IObject.

Definition at line 401 of file object.h.