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

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. More...
 
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. More...
 
- Public Member Functions inherited from object< IClassFactory >
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...
 

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 --> Use implemented Destroy() instead of delete!
 

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.

Member Function Documentation

◆ CreateInstance()

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 ucom::IClassFactory::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()

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 ucom::IClassInfo Object for the class given a template parameter

Definition at line 149 of file class_factory.h.

References RETURN_NOERROR.