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 declarations
26
27class CDevDescriptor;
28class CIOCommon;
29
36
37class CIOHandler : public CGenericHandler<CIOCommon>
38{
39public:
45
46 explicit CIOHandler()
47 : devDesc(nullptr)
48 , userFactory(nullptr)
49 {
50 }
51
60
62 {
63 devDesc = d;
64 }
65
71
72 ~CIOHandler() = default;
73
83
84 int init(CDescriptor &desc, IIOFactory *f);
85
93
94 int initAll() override;
95
103
104 int deinitAll() override
105 {
107 }
108
117
118 int startAll() override;
119
128
129 int stopAll() override;
130
136
137 bool hasThread() const override
138 {
140 }
141
150
151 bool isObjectValid(SObjectId::UObjectId &obj) const override;
152
161
162 CObject *getObject(const SObjectId::ObjectId id) override;
163
172
174
187
188 int bindObjects(IHandler &io, IHandler &prog, IHandler &prot, IHandler &dev);
189
190protected:
198
199 void onInitObject(CIOCommon *io) override;
200
206
207 const char *getObjectTypeName() const override
208 {
209 return "IO";
210 }
211
212private:
218
219 CDevDescriptor *devDesc;
220
226
227 CIOFactory factory;
228
234
235 IIOFactory *userFactory;
236
237#ifdef CONFIG_DAWN_IO_NOTIFY
244
245 CIONotifierManager notifyMgr;
246#endif
247
256
257 static void objallocPriv(CHandler &obj, CDescObject &desc);
258
267
268 int objalloc(CDescriptor &desc);
269
278
279 CIOCommon *create(CDescObject &desc);
280};
281} // Namespace dawn
Descriptor wrapper for individual object configuration.
Binary device descriptor manager.
Descriptor interface available for IO.
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:30
Built-in I/O object factory for standard I/O types.
Definition factory.hxx:39
const char * getObjectTypeName() const
Get human-readable object type name for logging.
Definition handler.hxx:207
int deinitAll()
De-initialize all I/O objects.
Definition handler.hxx:104
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:46
CObject * getObject(const SObjectId::ObjectId id)
Get object by ObjectID as CObject*.
Definition handler.cxx:185
void setDevDescriptor(CDevDescriptor *d)
Set the device descriptor instance.
Definition handler.hxx:61
~CIOHandler()=default
Destructor.
int stopAll()
Stop all I/O objects.
Definition handler.cxx:167
bool hasThread() const
Check if handler is currently running.
Definition handler.hxx:137
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:287
CIOCommon * getIO(SObjectId::UObjectId &id) const
Get I/O object by ObjectID as CIOCommon*.
Definition handler.cxx:192
bool isObjectValid(SObjectId::UObjectId &obj) const
Validate object ID.
Definition handler.cxx:180
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