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

Inheritance diagram for object< Bases >:
[legend]

Public Member Functions

tResult GetInterface (const tChar *i_strIID, tVoid *&o_pInterface) override
 Query interfaces on an object. More...
 
tResult GetInterface (const tChar *i_strIID, const tVoid *&o_pInterface) const override
 Provides const correct interface querying. More...
 
tVoid 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!
 

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
};

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 357 of file object.h.

Member Function Documentation

◆ Destroy()

tVoid Destroy ( ) const
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.

Returns
Nothing
See also
default_object to use the standard implementation.

Implements IObject.

Definition at line 374 of file object.h.

◆ GetInterface() [1/2]

tResult GetInterface ( const tChar i_strIID,
tVoid *&  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 364 of file object.h.

◆ GetInterface() [2/2]

tResult GetInterface ( const tChar i_strIID,
const tVoid *&  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 369 of file object.h.


Copyright © Audi Electronics Venture GmbH. All rights reserved. (Generated on Tue Nov 16 2021 by doxygen 1.8.14)