Dawn Framework 1.0
Universal data acquisition framework for embedded systems
descriptor.hxx
1// dawn/include/dawn/io/descriptor.hxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#pragma once
7
8#include "dawn/dev/descriptor.hxx"
9#include "dawn/io/common.hxx"
10#include "dawn/porting/config.hxx"
11
12namespace dawn
13{
21{
22public:
23 enum
24 {
25 IO_DESCRIPTOR_CFG_FIRST = 0,
26 IO_DESCRIPTOR_CFG_LAST = 31
27 };
28
29 explicit CIODescriptor(CDescObject &desc)
30 : CIOCommon(desc)
31 {
32 }
33
34 ~CIODescriptor() override;
35
36#ifdef CONFIG_DAWN_OBJECT_HAS_NAME
37 const char *getClassNameStr() const override
38 {
39 return "descriptor";
40 }
41#endif
42
43 int configure() override;
44 int deinit() override;
45 int getDataImpl(IODataCmn &data, size_t len) override;
46 int setDataImpl(IODataCmn &data) override;
47 int setDataAtImpl(IODataCmn &data, size_t offset) override;
48 int getDataAtImpl(IODataCmn &data, size_t len, size_t offset) override;
49
50#ifdef CONFIG_DAWN_IO_NOTIFY
51 int getFd() const override;
52#endif
53
54 size_t getDataSize() const override;
55 size_t getDataDim() const override;
56
57 bool isRead() const override
58 {
59 return true;
60 };
61
62 bool isWrite() const override
63 {
64 return getCmnDevno() != 0;
65 };
66
67 bool isNotify() const override
68 {
69 return true;
70 };
71
72 bool isBatch() const override
73 {
74 return false;
75 };
76
77 bool isSeekable() const override
78 {
79 return true;
80 }
81
82 using ObjectIdHelper =
84
85 constexpr static SObjectId::ObjectId objectId(uint16_t inst)
86 {
87 return ObjectIdHelper::create(inst);
88 }
89
90private:
91 CDevDescriptor::SDescriptorReg regDesc = {};
92
93 int configureDesc(const CDescObject &desc);
94};
95} // Namespace dawn
Descriptor wrapper for individual object configuration.
Template helper for creating ObjectIDs for I/O types without timestamp support.
Definition common.hxx:303
static SObjectId::ObjectId create(uint16_t inst)
Create ObjectID with fixed data type and no timestamp.
Definition common.hxx:312
Base class for all I/O objects.
Definition common.hxx:27
virtual int getFd() const
Get file descriptor for notifications.
Definition common.hxx:425
int getCmnDevno() const
Get device number for this I/O.
Definition common.hxx:798
Device descriptor I/O access.
bool isNotify() const
Check if IO supports notifications.
int deinit()
De-initialize object.
int setDataImpl(IODataCmn &data)
Set data implementation (override in derived classes).
size_t getDataSize() const
Get data size in bytes.
int getDataImpl(IODataCmn &data, size_t len)
Get data implementation (override in derived classes).
bool isWrite() const
Check if IO supports write operations.
int configure()
Configure object from descriptor data.
bool isSeekable() const
Check if IO supports partial (seekable) access.
int setDataAtImpl(IODataCmn &data, size_t offset)
Set data at byte offset (override in seekable IOs).
int getDataAtImpl(IODataCmn &data, size_t len, size_t offset)
Get data at byte offset (override in seekable IOs).
bool isRead() const
Check if IO supports read operations.
bool isBatch() const
Check if IO supports batch operations.
size_t getDataDim() const
Get data vector dimension.
Out-of-tree user-extension hooks for Dawn.
Definition bindable.hxx:13
Base interface for I/O data buffers (static and dynamic).
Definition idata.hxx:21
uint32_t ObjectId
ObjectID type - single 32-bit value.
Definition objectid.hxx:44