Dawn Framework 1.0
Universal data acquisition framework for embedded systems
vecpack.hxx
1// dawn/include/dawn/prog/vecpack.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;
17class CIOVirt;
18
27{
28public:
29 enum
30 {
31 PROG_VECPACK_CFG_FIRST = 0,
32 PROG_VECPACK_CFG_INPUTS = 1,
33 PROG_VECPACK_CFG_OUTPUT = 2,
34 PROG_VECPACK_CFG_LAST = 31
35 };
36
37 explicit CProgVecPack(CDescObject &desc);
38 ~CProgVecPack() override;
39
40#ifdef CONFIG_DAWN_OBJECT_HAS_NAME
41 const char *getClassNameStr() const override
42 {
43 return "vecpack";
44 }
45#endif
46
47 int configure() override;
48 int init() override;
49 int deinit() override;
50 int doStart() override;
51 int doStop() override;
52 bool hasThread() const override;
53
54 constexpr static SObjectId::ObjectId objectId(uint16_t inst)
55 {
57 SObjectId::OBJTYPE_PROG, CProgCommon::PROG_CLASS_VECPACK, SObjectId::DTYPE_ANY, 0, inst);
58 }
59
60 constexpr static SObjectCfg::ObjectCfgId cfgId(bool rw, uint8_t size, uint8_t id)
61 {
63 SObjectId::OBJTYPE_PROG, CProgCommon::PROG_CLASS_VECPACK, SObjectId::DTYPE_ANY, rw, size, id);
64 }
65
66 constexpr static SObjectCfg::ObjectCfgId cfgIdInputs(uint16_t size)
67 {
68 return CProgVecPack::cfgId(false, size, PROG_VECPACK_CFG_INPUTS);
69 }
70
71 constexpr static SObjectCfg::ObjectCfgId cfgIdOutput()
72 {
73 return CProgVecPack::cfgId(false, 1, PROG_VECPACK_CFG_OUTPUT);
74 }
75
76private:
77 struct SVecInput
78 {
79 CProgVecPack *owner;
80 CIOCommon *io;
82 io_ddata_t *data;
83 size_t offset;
84 bool usesSetCallback;
85 };
86
87 std::vector<SVecInput> inputs;
88 CIOCommon *output;
89 SObjectId::ObjectId outputId;
90 io_ddata_t *outputData;
91 io_ddata_t *lastOutputData;
92 bool active;
93 bool registered;
94
95 static int ioNotifierCb(void *priv, io_ddata_t *data);
96 static void ioSetCb(CIOVirt *io, void *priv);
97
98 int configureDesc(const CDescObject &desc);
99 int allocInput(SObjectId::ObjectId ioId);
100 void updateOutput();
101};
102} // namespace dawn
Descriptor wrapper for individual object configuration.
Base class for all I/O objects.
Definition common.hxx:27
Virtual I/O type for user-provided data and callbacks.
Definition virt.hxx:26
Base class for all PROG (processing) objects.
Definition common.hxx:27
Vector packer: combines multiple IO values into one vector IO.
Definition vecpack.hxx:27
int doStop()
Stop implementation hook.
Definition vecpack.cxx:293
int deinit()
De-initialize object.
Definition vecpack.cxx:198
bool hasThread() const
Check if a background thread is active.
Definition vecpack.cxx:322
int configure()
Configure object from descriptor data.
Definition vecpack.cxx:118
int doStart()
Start implementation hook.
Definition vecpack.cxx:250
int init()
One-time initialize object after bindings are resolved.
Definition vecpack.cxx:123
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