13#include "dawn/common/descriptor.hxx"
14#include "dawn/common/handler.hxx"
15#include "dawn/common/objectid.hxx"
16#include "dawn/debug.hxx"
39 DAWNASSERT(obj !=
nullptr,
"invalid input");
42 if (tmp->getIdV() == obj->getIdV())
44 DAWNERR(
"Duplicate object ID 0x%" PRIx32
"\n", obj->getIdV());
90#ifdef CONFIG_DAWN_LIFECYCLE_TEARDOWN
100 DAWNINFO(
"delete 0x%" PRIx32
"\n", obj->getIdV());
121 ret = obj->configure();
124 DAWNERR(
"Failed to configure %s 0x%" PRIx32
" (error %d)\n",
151 DAWNERR(
"Failed to init %s 0x%" PRIx32
" (error %d)\n",
173#ifdef CONFIG_DAWN_LIFECYCLE_TEARDOWN
185 DAWNERR(
"Failed to deinit %s 0x%" PRIx32
" (error %d)\n",
227 DAWNERR(
"Failed to start %s 0x%" PRIx32
" (error %d)\n",
248#ifdef CONFIG_DAWN_LIFECYCLE_TEARDOWN
258 DAWNERR(
"Failed to stop %s 0x%" PRIx32
" (error %d)\n",
281 objects.begin(),
objects.end(), [](
const T *obj) { return obj->hasThread(); });
291#ifdef CONFIG_DAWN_INSPECT
325 auto it = std::find_if(
326 objects.begin(),
objects.end(), [&
id](
const T *obj) { return obj->getIdV() == id.v; });
327 return (it !=
objects.end()) ? *it :
nullptr;
342 desc.alloc_objects(*
this, func);
Binary device descriptor manager.
std::function< void(CHandler &obj, CDescObject &desc)> allocobj_func_t
Thread function callback storage.
Template handler for object lifecycle management.
virtual const char * getObjectTypeName() const
Get object type name for logging.
int initAll()
Run one-time init() for all configured objects.
size_t getObjectCount() const
Get total number of registered objects.
virtual void onInitObject(T *obj)
Hook for subclass-specific post-object-init handling.
bool hasThread() const
Check if any thread is currently running.
virtual void onStartObject(T *obj)
Hook for subclass-specific pre-start operations.
int registerObject(T *obj)
Register object.
int stopAll()
Stop all objects managed by this handler.
const std::vector< T * > & getObjects() const
Get read-only access to all objects.
int deinitAll()
De-initialize all objects managed by this handler.
T * getObjectById(const SObjectId::UObjectId &id) const
Get object by ObjectID.
int configureAll()
Configure all objects managed by this handler.
~CGenericHandler()
Destructor.
std::vector< T * > objects
Vector of registered objects.
int objalloc(CDescriptor &desc, CDescriptor::allocobj_func_t func)
Allocate objects from descriptor.
int startAll()
Start all objects managed by this handler.
T * getObjectAt(size_t index) const
Get object at index.
Base implementation of IHandler interface.
Out-of-tree user-extension hooks for Dawn.
32-bit encoded object identifier (union with bit field).