Dawn Framework 1.0
Universal data acquisition framework for embedded systems
bindable.cxx
1// dawn/src/common/bindable.cxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#include "dawn/common/bindable.hxx"
7
8#include "dawn/debug.hxx"
9#include "dawn/io/common.hxx"
10
11using namespace dawn;
12
13void CBindableObject::setIOMapItem(SObjectId::ObjectId id, CIOCommon *io)
14{
15 ioMap.insert_or_assign(id, io);
16}
17
18const std::map<SObjectId::ObjectId, CIOCommon *> &CBindableObject::getIOMap() const
19{
20 return ioMap;
21}
22
24{
26 {
28 {
29 setIOMapItem(id, static_cast<CIOCommon *>(obj));
30 break;
31 }
32
33 default:
34 {
35 DAWNERR("Unsupported object type 0x%x for binding\n", SObjectId::objectIdGetType(id));
36 break;
37 }
38 }
39}
40
42{
43 auto it = ioMap.find(id);
44 if (it == ioMap.end())
45 {
46 return nullptr;
47 }
48
49 return it->second;
50}
51
53{
55 {
56 return getIO(id);
57 }
58
59 DAWNERR("unknown object type = 0x%" PRIx32 "\n", id);
60 return nullptr;
61}
CObject * getObject(SObjectId::ObjectId id)
Get an object by ID.
Definition bindable.cxx:52
CIOCommon * getIO(SObjectId::ObjectId id)
Get an I/O object by ID.
Definition bindable.cxx:41
void setObjectMapItem(SObjectId::ObjectId id, CObject *obj)
Set an item in the object map.
Definition bindable.cxx:23
const std::map< SObjectId::ObjectId, CIOCommon * > & getIOMap() const
Get the I/O map for this object.
Definition bindable.cxx:18
Base class for all I/O objects.
Definition common.hxx:27
Base class for all Dawn objects (IOs, Programs, Protocols).
Definition object.hxx:28
Out-of-tree user-extension hooks for Dawn.
Definition bindable.hxx:13
@ OBJTYPE_IO
Input/Output object type.
Definition objectid.hxx:184
static uint8_t objectIdGetType(const ObjectId objid)
Extract object type from ObjectID.
Definition objectid.hxx:361
uint32_t ObjectId
ObjectID type - single 32-bit value.
Definition objectid.hxx:44