Dawn Framework 1.0
Universal data acquisition framework for embedded systems
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
dawn::CGenericHandler< T > Class Template Referenceabstract

Template handler for object lifecycle management. More...

#include <generic_handler.hxx>

Inheritance diagram for dawn::CGenericHandler< T >:
[legend]
Collaboration diagram for dawn::CGenericHandler< T >:
[legend]

Public Member Functions

 ~CGenericHandler ()
 Destructor.
 
int configureAll ()
 Configure all objects managed by this handler.
 
int deinitAll ()
 De-initialize all objects managed by this handler.
 
virtual CObjectgetObject (const SObjectId::ObjectId id)=0
 Get object from this handler by ID.
 
T * getObjectAt (size_t index) const
 Get object at index.
 
T * getObjectById (const SObjectId::UObjectId &id) const
 Get object by ObjectID.
 
size_t getObjectCount () const
 Get total number of registered objects.
 
const std::vector< T * > & getObjects () const
 Get read-only access to all objects.
 
bool hasThread () const
 Check if any thread is currently running.
 
int initAll ()
 Run one-time init() for all configured objects.
 
virtual bool isObjectValid (SObjectId::UObjectId &obj) const =0
 Validate if object ID is valid for this handler.
 
int objalloc (CDescriptor &desc, CDescriptor::allocobj_func_t func)
 Allocate objects from descriptor.
 
int startAll ()
 Start all objects managed by this handler.
 
int stopAll ()
 Stop all objects managed by this handler.
 

Protected Member Functions

virtual const char * getObjectTypeName () const
 Get object type name for logging.
 
virtual void onInitObject (T *obj)
 Hook for subclass-specific post-object-init handling.
 
virtual void onStartObject (T *obj)
 Hook for subclass-specific pre-start operations.
 
int registerObject (T *obj)
 Register object.
 

Protected Attributes

std::vector< T * > objects
 Vector of registered objects.
 

Detailed Description

template<typename T>
class dawn::CGenericHandler< T >

Template handler for object lifecycle management.

Definition at line 23 of file generic_handler.hxx.

Constructor & Destructor Documentation

◆ ~CGenericHandler()

template<typename T >
dawn::CGenericHandler< T >::~CGenericHandler ( )
inline

Destructor.

Performs stop/delete cleanup only when lifecycle teardown is enabled.

Definition at line 88 of file generic_handler.hxx.

References dawn::CGenericHandler< T >::getObjectTypeName(), and dawn::CGenericHandler< T >::objects.

Here is the call graph for this function:

Member Function Documentation

◆ configureAll()

template<typename T >
int dawn::CGenericHandler< T >::configureAll ( )
inline

Configure all objects managed by this handler.

Returns
OK on success, negative error code on failure.

Definition at line 114 of file generic_handler.hxx.

References dawn::CGenericHandler< T >::getObjectTypeName(), and dawn::CGenericHandler< T >::objects.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ deinitAll()

template<typename T >
int dawn::CGenericHandler< T >::deinitAll ( )
inlinevirtual

De-initialize all objects managed by this handler.

Returns OK without cleanup when lifecycle teardown is disabled.

Returns
OK on success, negative error code on failure.

Implements dawn::IHandler.

Reimplemented in dawn::CIOHandler, dawn::CProgHandler, and dawn::CProtoHandler.

Definition at line 171 of file generic_handler.hxx.

References dawn::CGenericHandler< T >::getObjectTypeName(), and dawn::CGenericHandler< T >::objects.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getObject()

virtual CObject * dawn::IHandler::getObject ( const SObjectId::ObjectId  id)
pure virtualinherited

Get object from this handler by ID.

Retrieves a specific object by its ID.

Parameters
idObject ID.
Returns
Pointer to CObject if found, nullptr if not found.

Implemented in dawn::CIOHandler, dawn::CProgHandler, and dawn::CProtoHandler.

◆ getObjectAt()

template<typename T >
T * dawn::CGenericHandler< T >::getObjectAt ( size_t  index) const
inline

Get object at index.

Parameters
indexZero-based index.
Returns
Pointer to object, nullptr if out of bounds.

Definition at line 311 of file generic_handler.hxx.

References dawn::CGenericHandler< T >::objects.

◆ getObjectById()

template<typename T >
T * dawn::CGenericHandler< T >::getObjectById ( const SObjectId::UObjectId id) const
inline

Get object by ObjectID.

Parameters
idObjectID to retrieve.
Returns
Pointer to object, nullptr if not found.

Definition at line 323 of file generic_handler.hxx.

References dawn::CGenericHandler< T >::objects.

Here is the caller graph for this function:

◆ getObjects()

template<typename T >
const std::vector< T * > & dawn::CGenericHandler< T >::getObjects ( ) const
inline

Get read-only access to all objects.

Returns
Const reference to object vector.

Definition at line 298 of file generic_handler.hxx.

References dawn::CGenericHandler< T >::objects.

Here is the caller graph for this function:

◆ hasThread()

template<typename T >
bool dawn::CGenericHandler< T >::hasThread ( ) const
inlinevirtual

Check if any thread is currently running.

Returns
True if at least one object is running.

Implements dawn::IHandler.

Reimplemented in dawn::CIOHandler, dawn::CProgHandler, and dawn::CProtoHandler.

Definition at line 278 of file generic_handler.hxx.

References dawn::CGenericHandler< T >::objects.

Here is the caller graph for this function:

◆ initAll()

template<typename T >
int dawn::CGenericHandler< T >::initAll ( )
inlinevirtual

Run one-time init() for all configured objects.

Returns
OK on success, negative error code on failure.

Implements dawn::IHandler.

Reimplemented in dawn::CIOHandler, dawn::CProgHandler, and dawn::CProtoHandler.

Definition at line 141 of file generic_handler.hxx.

References dawn::CGenericHandler< T >::getObjectTypeName(), dawn::CGenericHandler< T >::objects, and dawn::CGenericHandler< T >::onInitObject().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isObjectValid()

virtual bool dawn::IHandler::isObjectValid ( SObjectId::UObjectId obj) const
pure virtualinherited

Validate if object ID is valid for this handler.

Checks whether a given object ID represents a valid object managed by this handler.

Parameters
objObject ID to validate.
Returns
True if object ID is valid for this handler, false otherwise.

Implemented in dawn::CIOHandler, dawn::CProgHandler, and dawn::CProtoHandler.

◆ objalloc()

template<typename T >
int dawn::CGenericHandler< T >::objalloc ( CDescriptor desc,
CDescriptor::allocobj_func_t  func 
)
inline

Allocate objects from descriptor.

Generic descriptor allocation using callback pattern.

Parameters
descDevice descriptor containing object definitions.
funcStatic callback: void func(CHandler& handler, CDescObject&).

Definition at line 339 of file generic_handler.hxx.

◆ onInitObject()

template<typename T >
virtual void dawn::CGenericHandler< T >::onInitObject ( T *  obj)
inlineprotectedvirtual

Hook for subclass-specific post-object-init handling.

Parameters
objPointer to object that was just initialized.

Reimplemented in dawn::CIOHandler.

Definition at line 60 of file generic_handler.hxx.

Here is the caller graph for this function:

◆ onStartObject()

template<typename T >
virtual void dawn::CGenericHandler< T >::onStartObject ( T *  obj)
inlineprotectedvirtual

Hook for subclass-specific pre-start operations.

Parameters
objPointer to object about to start.

Definition at line 70 of file generic_handler.hxx.

Here is the caller graph for this function:

◆ registerObject()

template<typename T >
int dawn::CGenericHandler< T >::registerObject ( T *  obj)
inlineprotected

Register object.

Parameters
objPointer to object to register.

Definition at line 37 of file generic_handler.hxx.

References dawn::CGenericHandler< T >::objects.

◆ startAll()

template<typename T >
int dawn::CGenericHandler< T >::startAll ( )
inlinevirtual

Start all objects managed by this handler.

Returns
OK on success, negative error code on failure.

Implements dawn::IHandler.

Reimplemented in dawn::CIOHandler, dawn::CProgHandler, and dawn::CProtoHandler.

Definition at line 216 of file generic_handler.hxx.

References dawn::CGenericHandler< T >::getObjectTypeName(), dawn::CGenericHandler< T >::objects, and dawn::CGenericHandler< T >::onStartObject().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stopAll()

template<typename T >
int dawn::CGenericHandler< T >::stopAll ( )
inlinevirtual

Stop all objects managed by this handler.

Returns OK without stopping objects when lifecycle teardown is disabled.

Returns
OK on success, negative error code on failure.

Implements dawn::IHandler.

Reimplemented in dawn::CIOHandler, dawn::CProgHandler, and dawn::CProtoHandler.

Definition at line 246 of file generic_handler.hxx.

References dawn::CGenericHandler< T >::getObjectTypeName(), and dawn::CGenericHandler< T >::objects.

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: