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

The class class_factory provides a template based implementation of the IClassFactory interface, that can create exactly one kind of object for the class. More...

#include <class_factory.h>

Inheritance diagram for class_factory< Classes >:
[legend]

Classes

struct  dispatch
 
struct  dispatch< Class, InnerClasses... >
 

Public Member Functions

 class_factory ()
 The Constructor create the class factory for exactly one object.
 
virtual ~class_factory ()
 standard DTOR for the class factory.
 
virtual tResult CreateInstance (const char *strCID, iobject_ptr< IObject > &oObject, const tChar *strNameOfObject="") const
 Creates a new instance.
 
tResult GetClasses (iobject_enum< const IClassInfo > &lstOfClasses) const
 Enumerates all classes supported by the class factory and pushes it to lstOfClasses This method should be used for debugging or testing purposes only.
 
- Public Member Functions inherited from object< IClassFactory >
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.
 
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.
 
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()
 

Private Member Functions

 class_factory (const class_factory &)=delete
 
 class_factory (class_factory &&)=delete
 
class_factoryoperator= (const class_factory &)=delete
 
class_factoryoperator= (class_factory &&)=delete
 

Additional Inherited Members

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

Detailed Description

template<typename ... Classes>
class adtf::ucom::ant::class_factory< Classes >

The class class_factory provides a template based implementation of the IClassFactory interface, that can create exactly one kind of object for the class.

Parameters
T.
Template Parameters
TClass of the Object to create.
EXPLICIT_INTERFACEIf the class implementation T has ambiguous conversion to the IObject use EXPLICIT_INTERFACE to define an explicit cast.

Definition at line 25 of file class_factory.h.

Constructor & Destructor Documentation

◆ class_factory()

template<typename ... Classes>
class_factory ( )
inline

The Constructor create the class factory for exactly one object.

Definition at line 103 of file class_factory.h.

◆ ~class_factory()

template<typename ... Classes>
virtual ~class_factory ( )
inlinevirtual

standard DTOR for the class factory.

Definition at line 110 of file class_factory.h.

Member Function Documentation

◆ CreateInstance()

template<typename ... Classes>
virtual tResult CreateInstance ( const char * strCID,
iobject_ptr< IObject > & oObject,
const tChar * strNameOfObject = "" ) const
inlinevirtual

Creates a new instance.

The CreateInstance method creates a single uninitialized object of the class associated with a specified class identifier.

Parameters
[in]strCIDClass identifier of the object to create!
[in]strNameOfObjectObjectName identifier (will be relevant only if the ClassFactory can handle this).
[in,out]oObjectObject to create to be used to communicate with the object.
Returns
Returns a standard result code.
Return values
ERR_ERR_INVALID_LICENSEno valid license found
ReturnValue of iobject_ptr<IObject>::Reset() Implements the CreateInstance. This Function will create an instance for given parameter class
<T>
.
ERR_INVALID_ARGstrCID is empty
ERR_MEMORYthe object will be created on heap. out of memory.
ERR_NO_CLASSGiven strCID is not supported by this class factory.
ERR_INVALID_INTERFACEoObject.Get() is empty after Reseting. This could be possible if the oObject expect another interface.

Definition at line 125 of file class_factory.h.

References RETURN_ERROR_DESC, and RETURN_IF_POINTER_NULL.

◆ GetClasses()

template<typename ... Classes>
tResult GetClasses ( iobject_enum< const IClassInfo > & lstOfClasses) const
inline

Enumerates all classes supported by the class factory and pushes it to lstOfClasses This method should be used for debugging or testing purposes only.

Parameters
[in,out]lstOfClassesList to return the class information to. Use object_list or object_vector.
Returns
Returns a standard result code.
See also
object_list, object_vector.

This function will fill the iobject_enum with only one IClassInfo Object for the class given a template parameter

Definition at line 149 of file class_factory.h.

References RETURN_NOERROR.