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
171 int bindObjects(IHandler &io, IHandler &prog, IHandler &prot);
172
173protected:
182 void onInitObject(CIOCommon *io) override;
183
190 const char *getObjectTypeName() const override
191 {
192 return "IO";
193 }
194
195private:
202 CIOFactory factory;
203
210 IIOFactory *userFactory;
211
212#ifdef CONFIG_DAWN_IO_NOTIFY
220 CIONotifierManager notifyMgr;
221#endif
222
232 static void objallocPriv(CHandler &obj, CDescObject &desc);
233
243 int objalloc(CDescriptor &desc);
244
254 CIOCommon *create(CDescObject &desc);
255};
256} // 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:190
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
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
int bindObjects(IHandler &io, IHandler &prog, IHandler &prot)
Bind special I/O objects (Config, Control, Trigger) to targets.
Definition handler.cxx:265
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