Dawn Framework 1.0
Universal data acquisition framework for embedded systems
handler.hxx
1// dawn/include/dawn/io/handler.hxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#pragma once
7
8#include "dawn/common/descriptor.hxx"
9#include "dawn/common/generic_handler.hxx"
10#include "dawn/common/handler.hxx"
11#include "dawn/io/common.hxx"
12#include "dawn/io/factory.hxx"
13#include "dawn/porting/config.hxx"
14
15#ifdef CONFIG_DAWN_IO_NOTIFY
16# include "dawn/io/notify_manager.hxx"
17#endif
18
19//***************************************************************************
20// Public Classes
21//***************************************************************************
22
23namespace dawn
24{
25// Forward declaration
26
27class CIOCommon;
28
36class CIOHandler : public CGenericHandler<CIOCommon>
37{
38public:
45 explicit CIOHandler()
46 : userFactory(nullptr)
47 {
48 }
49
56 ~CIOHandler() = default;
57
68 int init(CDescriptor &desc, IIOFactory *f);
69
78 int initAll() override;
79
88 int deinitAll() override
89 {
91 }
92
102 int startAll() override;
103
113 int stopAll() override;
114
121 bool hasThread() const override
122 {
124 }
125
135 bool isObjectValid(SObjectId::UObjectId &obj) const override;
136
146 CObject *getObject(const SObjectId::ObjectId id) override;
147
158
172 int bindObjects(IHandler &io, IHandler &prog, IHandler &prot, IHandler &dev);
173
174protected:
183 void onInitObject(CIOCommon *io) override;
184
191 const char *getObjectTypeName() const override
192 {
193 return "IO";
194 }
195
196private:
203 CIOFactory factory;
204
211 IIOFactory *userFactory;
212
213#ifdef CONFIG_DAWN_IO_NOTIFY
221 CIONotifierManager notifyMgr;
222#endif
223
233 static void objallocPriv(CHandler &obj, CDescObject &desc);
234
244 int objalloc(CDescriptor &desc);
245
255 CIOCommon *create(CDescObject &desc);
256};
257} // Namespace dawn
Descriptor wrapper for individual object configuration.
Binary device descriptor manager.
Template handler for object lifecycle management.
bool hasThread() const
Check if any thread is currently running.
int deinitAll()
De-initialize all objects managed by this handler.
Base implementation of IHandler interface.
Definition handler.hxx:110
Base class for all I/O objects.
Definition common.hxx:27
Built-in I/O object factory for standard I/O types.
Definition factory.hxx:39
Manages I/O object lifecycle and dispatch.
Definition handler.hxx:37
const char * getObjectTypeName() const
Get human-readable object type name for logging.
Definition handler.hxx:191
int deinitAll()
De-initialize all I/O objects.
Definition handler.hxx:88
void onInitObject(CIOCommon *io)
Hook called for each I/O object during initAll().
Definition handler.cxx:117
int startAll()
Start all I/O objects.
Definition handler.cxx:124
CIOHandler()
Construct I/O handler.
Definition handler.hxx:45
CObject * getObject(const SObjectId::ObjectId id)
Get object by ObjectID as CObject*.
Definition handler.cxx:174
~CIOHandler()=default
Destructor.
int stopAll()
Stop all I/O objects.
Definition handler.cxx:156
bool hasThread() const
Check if handler is currently running.
Definition handler.hxx:121
int initAll()
Configure and initialize all I/O objects.
Definition handler.cxx:135
int init(CDescriptor &desc, IIOFactory *f)
Initialize virtual I/O.
Definition handler.cxx:91
int bindObjects(IHandler &io, IHandler &prog, IHandler &prot, IHandler &dev)
Bind special I/O objects (Config, Control, Trigger) to targets.
Definition handler.cxx:276
CIOCommon * getIO(SObjectId::UObjectId &id) const
Get I/O object by ObjectID as CIOCommon*.
Definition handler.cxx:181
bool isObjectValid(SObjectId::UObjectId &obj) const
Validate object ID.
Definition handler.cxx:169
Manages notifier instances for I/O objects.
Base class for all Dawn objects (IOs, Programs, Protocols).
Definition object.hxx:28
Common interface for all handler implementations.
Definition handler.hxx:21
Abstract factory interface for extensible I/O object creation.
Definition factory.hxx:20
Out-of-tree user-extension hooks for Dawn.
Definition bindable.hxx:13
uint32_t ObjectId
ObjectID type - single 32-bit value.
Definition objectid.hxx:44
32-bit encoded object identifier (union with bit field).
Definition objectid.hxx:218