6#include "dawn/prog/onetomany.hxx"
8#include "dawn/debug.hxx"
9#include "dawn/io/common.hxx"
23CProgOneToMany::~CProgOneToMany()
30 outputIds.push_back(ioId);
31 outputs.push_back(
nullptr);
36int CProgOneToMany::configureDesc(
const CDescObject &desc)
38 const SObjectCfg::SObjectCfgItem *item;
39 const SObjectId::UObjectId *ids;
42 for (
size_t i = 0; i < desc.
getSize(); i++)
46 if (item->
cfgid.
s.
cls != CProgCommon::PROG_CLASS_ONETOMANY)
48 DAWNERR(
"onetomany: unsupported cfg class 0x%" PRIx32
"\n", item->
cfgid.
v);
54 case PROG_ONETOMANY_CFG_INPUT:
58 DAWNERR(
"onetomany: INPUT must have one item\n");
61 ids =
reinterpret_cast<const SObjectId::UObjectId *
>(item->
data);
67 case PROG_ONETOMANY_CFG_OUTPUTS:
71 DAWNERR(
"onetomany: OUTPUTS must not be empty\n");
74 ids =
reinterpret_cast<const SObjectId::UObjectId *
>(item->
data);
75 for (
size_t j = 0; j < item->
cfgid.
s.
size; j++)
77 int ret = allocOutput(ids[j].v);
87 DAWNERR(
"onetomany: unsupported cfg id %u\n", item->
cfgid.
s.
id);
92 if (inputId == 0 || outputs.empty())
94 DAWNERR(
"onetomany: input and outputs are required\n");
103 return configureDesc(
getDesc());
106int CProgOneToMany::validateShape(
CIOCommon *io)
const
108 if (io ==
nullptr || input ==
nullptr)
124 input =
getIO(inputId);
125 if (input ==
nullptr || !input->isRead() || !input->isNotify())
127 DAWNERR(
"onetomany: input 0x%" PRIx32
" is not readable notify IO\n", inputId);
131 for (
size_t i = 0; i < outputIds.size(); i++)
133 outputs[i] =
getIO(outputIds[i]);
134 if (outputs[i] ==
nullptr)
136 DAWNERR(
"onetomany: output IO 0x%" PRIx32
" not found\n", outputIds[i]);
143 DAWNERR(
"onetomany: output prepare failed %d\n", ret);
147 ret = validateShape(outputs[i]);
150 DAWNERR(
"onetomany: output 0x%" PRIx32
" incompatible\n", outputIds[i]);
155 dataBuf = input->ddata_alloc(1);
156 if (dataBuf ==
nullptr)
158 DAWNERR(
"onetomany: data allocation failed\n");
177int CProgOneToMany::ioNotifierCb(
void *priv,
io_ddata_t *data)
181 if (self ==
nullptr || !self->active || data ==
nullptr)
186 self->writeOutputs(data);
194 int ret = input->setNotifier(ioNotifierCb, 0,
this);
197 DAWNERR(
"onetomany: setNotifier failed %d\n", ret);
204 if (input->getData(*dataBuf, 1) == OK)
206 writeOutputs(dataBuf);
213 if (registered && input !=
nullptr)
215 input->setNotifier(
nullptr, 0,
nullptr);
228void CProgOneToMany::writeOutputs(
io_ddata_t *data)
230 for (
auto output : outputs)
232 int ret = output->setData(*data);
235 DAWNERR(
"onetomany: output setData failed %d\n", ret);
CIOCommon * getIO(SObjectId::ObjectId id)
Get an I/O object by ID.
void setObjectMapItem(SObjectId::ObjectId id, CObject *obj)
Set an item in the object map.
Descriptor wrapper for individual object configuration.
size_t getSize() const
Get number of configuration items for this object.
SObjectCfg::SObjectCfgItem * objectCfgItemNext(size_t &offset) const
Get config item at current offset and advance past it.
Base class for all I/O objects.
bool isTimestamp() const
Check if I/O supports timestamp.
virtual size_t getDataDim() const =0
Get data vector dimension.
virtual size_t getDataSize() const =0
Get data size in bytes.
CDescObject & getDesc()
Get descriptor object for this object.
uint8_t getDtype() const
Get data type field.
Base class for all PROG (processing) objects.
int prepareWritableTarget(CIOCommon *io, size_t dim, bool notify, size_t batch=1)
Check a writable output; shape a deferred virt output or check an already shaped one.
One-to-many bridge: forwards one input to many outputs.
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.
Out-of-tree user-extension hooks for Dawn.
ObjectCfgData_t data[]
Configuration data array (flexible, size from cfgid.s.size).
UObjectCfgId cfgid
Configuration ID header (type, class, id, size, rw, dtype).
uint32_t ObjectId
ObjectID type - single 32-bit value.
Heap-allocated dynamic I/O data buffer.
ObjectCfgId v
Raw 32-bit ConfigID value (for storage, comparison).
uint32_t cls
Object class (bits 21-29, max 511).
uint32_t id
Configuration identifier (bits 0-4, max 31).
struct dawn::SObjectCfg::UObjectCfgId::@334307326077356333363326153167141302007100111136 s
Bit-field structure for named member access.
uint32_t size
Configuration data size in 32-bit words (bits 5-14, max 1023).
ObjectId v
Raw 32-bit ObjectID value (for comparison, hashing, storage).