Dawn Framework 1.0
Universal data acquisition framework for embedded systems
onetomany.hxx
1// dawn/include/dawn/prog/onetomany.hxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#pragma once
7
8#include <inttypes.h>
9#include <vector>
10
11#include "dawn/io/ddata.hxx"
12#include "dawn/prog/common.hxx"
13
14namespace dawn
15{
16class CIOCommon;
17
22{
23public:
24 enum
25 {
26 PROG_ONETOMANY_CFG_FIRST = 0,
27 PROG_ONETOMANY_CFG_INPUT = 1,
28 PROG_ONETOMANY_CFG_OUTPUTS = 2,
29 PROG_ONETOMANY_CFG_LAST = 31
30 };
31
32 explicit CProgOneToMany(CDescObject &desc);
33 ~CProgOneToMany() override;
34
35#ifdef CONFIG_DAWN_OBJECT_HAS_NAME
36 const char *getClassNameStr() const override
37 {
38 return "onetomany";
39 }
40#endif
41
42 int configure() override;
43 int init() override;
44 int deinit() override;
45 int doStart() override;
46 int doStop() override;
47 bool hasThread() const override;
48
49 constexpr static SObjectId::ObjectId objectId(uint16_t inst)
50 {
52 SObjectId::OBJTYPE_PROG, CProgCommon::PROG_CLASS_ONETOMANY, SObjectId::DTYPE_ANY, 0, inst);
53 }
54
55 constexpr static SObjectCfg::ObjectCfgId cfgId(bool rw, uint8_t size, uint8_t id)
56 {
58 CProgCommon::PROG_CLASS_ONETOMANY,
60 rw,
61 size,
62 id);
63 }
64
65 constexpr static SObjectCfg::ObjectCfgId cfgIdInput()
66 {
67 return CProgOneToMany::cfgId(false, 1, PROG_ONETOMANY_CFG_INPUT);
68 }
69
70 constexpr static SObjectCfg::ObjectCfgId cfgIdOutputs(uint16_t size)
71 {
72 return CProgOneToMany::cfgId(false, size, PROG_ONETOMANY_CFG_OUTPUTS);
73 }
74
75private:
76 CIOCommon *input;
77 SObjectId::ObjectId inputId;
78 std::vector<CIOCommon *> outputs;
79 std::vector<SObjectId::ObjectId> outputIds;
80 io_ddata_t *dataBuf;
81 bool active;
82 bool registered;
83
84 static int ioNotifierCb(void *priv, io_ddata_t *data);
85
86 int configureDesc(const CDescObject &desc);
87 int allocOutput(SObjectId::ObjectId ioId);
88 int validateShape(CIOCommon *io) const;
89 void writeOutputs(io_ddata_t *data);
90};
91} // namespace dawn
Descriptor wrapper for individual object configuration.
Base class for all I/O objects.
Definition common.hxx:27
Base class for all PROG (processing) objects.
Definition common.hxx:27
One-to-many bridge: forwards one input to many outputs.
Definition onetomany.hxx:22
int init()
One-time initialize object after bindings are resolved.
int configure()
Configure object from descriptor data.
bool hasThread() const
Check if a background thread is active.
int deinit()
De-initialize object.
int doStop()
Stop implementation hook.
int doStart()
Start implementation hook.
static ObjectCfgId objectCfg(uint8_t type, uint16_t cls, uint8_t dtype, bool rw, uint16_t size, uint8_t id)
Construct 32-bit ConfigID from component fields.
uint32_t ObjectCfgId
ConfigID type - single 32-bit value.
Definition objectcfg.hxx:60
Out-of-tree user-extension hooks for Dawn.
Definition bindable.hxx:13
@ OBJTYPE_PROG
Program/algorithm object type.
Definition objectid.hxx:202
@ DTYPE_ANY
Wildcard data type (matches any actual type).
Definition objectid.hxx:68
uint32_t ObjectId
ObjectID type - single 32-bit value.
Definition objectid.hxx:44
static ObjectId objectId(uint8_t type, uint16_t cls, uint8_t dtype, uint8_t flags, uint16_t priv)
Construct 32-bit ObjectID from component fields.
Definition objectid.hxx:290
Heap-allocated dynamic I/O data buffer.
Definition ddata.hxx:21