Dawn Framework 1.0
Universal data acquisition framework for embedded systems
manytoone.hxx
1// dawn/include/dawn/prog/manytoone.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_MANYTOONE_CFG_FIRST = 0,
27 PROG_MANYTOONE_CFG_INPUTS = 1,
28 PROG_MANYTOONE_CFG_OUTPUT = 2,
29 PROG_MANYTOONE_CFG_LAST = 31
30 };
31
32 explicit CProgManyToOne(CDescObject &desc);
33 ~CProgManyToOne() override;
34
35#ifdef CONFIG_DAWN_OBJECT_HAS_NAME
36 const char *getClassNameStr() const override
37 {
38 return "manytoone";
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_MANYTOONE, 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_MANYTOONE,
60 rw,
61 size,
62 id);
63 }
64
65 constexpr static SObjectCfg::ObjectCfgId cfgIdInputs(uint16_t size)
66 {
67 return CProgManyToOne::cfgId(false, size, PROG_MANYTOONE_CFG_INPUTS);
68 }
69
70 constexpr static SObjectCfg::ObjectCfgId cfgIdOutput()
71 {
72 return CProgManyToOne::cfgId(false, 1, PROG_MANYTOONE_CFG_OUTPUT);
73 }
74
75private:
76 struct SInput
77 {
78 CProgManyToOne *owner;
79 CIOCommon *io;
81 };
82
83 std::vector<SInput> inputs;
84 CIOCommon *output;
85 SObjectId::ObjectId outputId;
86 io_ddata_t *dataBuf;
87 bool active;
88 bool registered;
89
90 static int ioNotifierCb(void *priv, io_ddata_t *data);
91
92 int configureDesc(const CDescObject &desc);
93 int allocInput(SObjectId::ObjectId ioId);
94 int validateShape(CIOCommon *io) const;
95 void writeInput(size_t index);
96};
97} // 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
Many-to-one bridge: forwards the last changed input to one output.
Definition manytoone.hxx:22
bool hasThread() const
Check if a background thread is active.
int doStart()
Start implementation hook.
int init()
One-time initialize object after bindings are resolved.
int deinit()
De-initialize object.
int doStop()
Stop implementation hook.
int configure()
Configure object from descriptor data.
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