Dawn Framework 1.0
Universal data acquisition framework for embedded systems
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
dawn::CIOHandler Class Reference

Manages I/O object lifecycle and dispatch. More...

#include <handler.hxx>

Inheritance diagram for dawn::CIOHandler:
[legend]
Collaboration diagram for dawn::CIOHandler:
[legend]

Public Member Functions

 CIOHandler ()
 Construct I/O handler.
 
 ~CIOHandler ()=default
 Destructor.
 
int bindObjects (IHandler &io, IHandler &prog, IHandler &prot, IHandler &dev)
 Bind special I/O objects (Config, Control, Trigger) to targets.
 
int configureAll ()
 Configure all objects managed by this handler.
 
int deinitAll ()
 De-initialize all I/O objects.
 
CIOCommongetIO (SObjectId::UObjectId &id) const
 Get I/O object by ObjectID as CIOCommon*.
 
CObjectgetObject (const SObjectId::ObjectId id)
 Get object by ObjectID as CObject*.
 
CIOCommongetObjectAt (size_t index) const
 Get object at index.
 
CIOCommongetObjectById (const SObjectId::UObjectId &id) const
 Get object by ObjectID.
 
size_t getObjectCount () const
 Get total number of registered objects.
 
const std::vector< CIOCommon * > & getObjects () const
 Get read-only access to all objects.
 
bool hasThread () const
 Check if handler is currently running.
 
int init (CDescriptor &desc, IIOFactory *f)
 Initialize virtual I/O.
 
int initAll ()
 Configure and initialize all I/O objects.
 
bool isObjectValid (SObjectId::UObjectId &obj) const
 Validate object ID.
 
int objalloc (CDescriptor &desc, CDescriptor::allocobj_func_t func)
 Allocate objects from descriptor.
 
int startAll ()
 Start all I/O objects.
 
int stopAll ()
 Stop all I/O objects.
 

Protected Member Functions

const char * getObjectTypeName () const
 Get human-readable object type name for logging.
 
void onInitObject (CIOCommon *io)
 Hook called for each I/O object during initAll().
 
virtual void onStartObject (CIOCommon *obj)
 Hook for subclass-specific pre-start operations.
 
int registerObject (CIOCommon *obj)
 Register object.
 

Protected Attributes

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

Detailed Description

Manages I/O object lifecycle and dispatch.

Creates, initializes, starts, stops, and provides lookup for all I/O objects in the system.

Definition at line 36 of file handler.hxx.

Constructor & Destructor Documentation

◆ CIOHandler()

dawn::CIOHandler::CIOHandler ( )
inlineexplicit

Construct I/O handler.

Creates empty handler with no objects.

Definition at line 45 of file handler.hxx.

◆ ~CIOHandler()

dawn::CIOHandler::~CIOHandler ( )
default

Destructor.

All I/O objects are destroyed here if deinitAll() was not called.

Member Function Documentation

◆ bindObjects()

int CIOHandler::bindObjects ( IHandler io,
IHandler prog,
IHandler prot,
IHandler dev 
)

Bind special I/O objects (Config, Control, Trigger) to targets.

Iterates all IOs and resolves bound target object IDs for special IO types against all three handlers. Called after all initAll() phases.

Parameters
ioI/O handler for resolving IO targets.
progPROG handler for resolving program targets.
protPROTO handler for resolving protocol targets.
devDEV handler for resolving OBJTYPE_ANY dev-object targets.
Returns
OK on success, negative error code on failure.

Definition at line 276 of file handler.cxx.

References dawn::CObject::getCls(), dawn::CIOControl::ids, dawn::CIOTrigger::ids, dawn::CIOCommon::IO_CLASS_CONFIG, dawn::CIOCommon::IO_CLASS_CONTROL, dawn::CIOCommon::IO_CLASS_TRIGGER, dawn::CIOConfig::map, and dawn::CGenericHandler< CIOCommon >::objects.

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

◆ configureAll()

int dawn::CGenericHandler< CIOCommon >::configureAll ( )
inlineinherited

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.

◆ deinitAll()

int dawn::CIOHandler::deinitAll ( )
inlinevirtual

De-initialize all I/O objects.

Calls deinit() method on each I/O object in reverse order.

Returns
OK if all objects deinitialized, first error otherwise.

Reimplemented from dawn::CGenericHandler< CIOCommon >.

Definition at line 88 of file handler.hxx.

References dawn::CGenericHandler< T >::deinitAll().

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

◆ getIO()

CIOCommon * CIOHandler::getIO ( SObjectId::UObjectId id) const

Get I/O object by ObjectID as CIOCommon*.

Implements IIOHandler interface.

Parameters
idReference to ObjectID to retrieve.
Returns
Pointer to CIOCommon object or nullptr if not found.

Definition at line 181 of file handler.cxx.

References dawn::CGenericHandler< T >::getObjectById().

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

◆ getObject()

CObject * CIOHandler::getObject ( const SObjectId::ObjectId  id)
virtual

Get object by ObjectID as CObject*.

Returns object as CObject pointer for generic handler operations.

Parameters
idObjectID to retrieve.
Returns
Pointer to CObject (CIOCommon*) or nullptr if not found.

Implements dawn::IHandler.

Definition at line 174 of file handler.cxx.

References getIO(), and dawn::SObjectId::UObjectId::v.

Here is the call graph for this function:

◆ getObjectAt()

CIOCommon * dawn::CGenericHandler< CIOCommon >::getObjectAt ( size_t  index) const
inlineinherited

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.

◆ getObjectById()

CIOCommon * dawn::CGenericHandler< CIOCommon >::getObjectById ( const SObjectId::UObjectId id) const
inlineinherited

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.

◆ getObjects()

const std::vector< CIOCommon * > & dawn::CGenericHandler< CIOCommon >::getObjects ( ) const
inlineinherited

Get read-only access to all objects.

Returns
Const reference to object vector.

Definition at line 298 of file generic_handler.hxx.

◆ getObjectTypeName()

const char * dawn::CIOHandler::getObjectTypeName ( ) const
inlineprotectedvirtual

Get human-readable object type name for logging.

Returns
String "IO" for I/O objects.

Reimplemented from dawn::CGenericHandler< CIOCommon >.

Definition at line 191 of file handler.hxx.

◆ hasThread()

bool dawn::CIOHandler::hasThread ( ) const
inlinevirtual

Check if handler is currently running.

Returns
True if startAll() has been called and stopAll() has not.

Reimplemented from dawn::CGenericHandler< CIOCommon >.

Definition at line 121 of file handler.hxx.

References dawn::CGenericHandler< T >::hasThread().

Here is the call graph for this function:

◆ init()

int CIOHandler::init ( CDescriptor desc,
IIOFactory f 
)

Initialize virtual I/O.

Allocates internal data structures.

Parameters
descDevice descriptor containing I/O definitions.
fOptional user factory for custom I/O types (can be null).
Returns
OK on success, negative error code on failure.

Definition at line 91 of file handler.cxx.

References dawn::CDevInspector::getInst(), and dawn::CDevInspector::registerIOHandler().

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

◆ initAll()

int CIOHandler::initAll ( )
virtual

Configure and initialize all I/O objects.

Runs configure/init lifecycle passes for each I/O object in order.

Returns
OK if all objects initialized, first error otherwise.

Reimplemented from dawn::CGenericHandler< CIOCommon >.

Definition at line 135 of file handler.cxx.

References dawn::CGenericHandler< T >::configureAll(), and dawn::CGenericHandler< T >::initAll().

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

◆ isObjectValid()

bool CIOHandler::isObjectValid ( SObjectId::UObjectId obj) const
virtual

Validate object ID.

Checks if an ObjectID refers to a valid I/O object in this handler.

Parameters
objReference to ObjectID to validate.
Returns
True if object exists, false otherwise.

Implements dawn::IHandler.

Definition at line 169 of file handler.cxx.

References dawn::SObjectId::objectIsIO().

Here is the call graph for this function:

◆ objalloc()

int dawn::CGenericHandler< CIOCommon >::objalloc ( CDescriptor desc,
CDescriptor::allocobj_func_t  func 
)
inlineinherited

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()

void CIOHandler::onInitObject ( CIOCommon io)
protectedvirtual

Hook called for each I/O object during initAll().

Called by CGenericHandler::initAll() after init() on each object.

Parameters
ioPointer to I/O object just initialized.

Reimplemented from dawn::CGenericHandler< CIOCommon >.

Definition at line 117 of file handler.cxx.

◆ onStartObject()

virtual void dawn::CGenericHandler< CIOCommon >::onStartObject ( CIOCommon obj)
inlineprotectedvirtualinherited

Hook for subclass-specific pre-start operations.

Parameters
objPointer to object about to start.

Definition at line 70 of file generic_handler.hxx.

◆ registerObject()

int dawn::CGenericHandler< CIOCommon >::registerObject ( CIOCommon obj)
inlineprotectedinherited

Register object.

Parameters
objPointer to object to register.

Definition at line 37 of file generic_handler.hxx.

◆ startAll()

int CIOHandler::startAll ( )
virtual

Start all I/O objects.

Calls start() method on each I/O object and starts the notifier thread (if CONFIG_DAWN_IO_NOTIFY enabled).

Returns
OK if all started, first error otherwise.

Reimplemented from dawn::CGenericHandler< CIOCommon >.

Definition at line 124 of file handler.cxx.

References dawn::CGenericHandler< T >::startAll().

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

◆ stopAll()

int CIOHandler::stopAll ( )
virtual

Stop all I/O objects.

Stops the notifier thread (if CONFIG_DAWN_IO_NOTIFY enabled) and calls stop() method on each I/O object in reverse order.

Returns
OK if all stopped, first error otherwise.

Reimplemented from dawn::CGenericHandler< CIOCommon >.

Definition at line 156 of file handler.cxx.

References dawn::CGenericHandler< T >::stopAll().

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 files: