IOLink IOL_v1.8.0_release
Loading...
Searching...
No Matches
RandomAccess.h
1#pragma once
2
3#include <iolink/FlagSet.h>
4#include <iolink/IOLinkAPI.h>
5#include <iolink/storage/DataAccess.h>
6
7#include <cstdint>
8
9namespace iolink
10{
11
16{
17 READ = 0x1,
18 WRITE = 0x2,
19 RESIZE = 0x4,
20 MEMORY_ACCESS = 0x8,
21
22 READ_WRITE = 0x3,
23 WRITE_RESIZE = 0x6,
24};
25
26extern template class IOLINK_API_IMPORT FlagSet<RandomAccessCapability>;
27
30
31// Define bitwise operators for RandomAccessCapability
32IOLINK_DEFINE_ENUM_BITWISE_OPERATORS(RandomAccessCapability)
33
34
45class IOLINK_API RandomAccess : public DataAccess
46{
47public:
48 virtual ~RandomAccess() = default;
49
54
58 inline bool support(RandomAccessCapabilitySet flags) { return this->capabilities().has(flags); }
59
63 virtual size_t size() const = 0;
64
68 std::string toString() const;
69
70 // ==== //
71 // READ //
72 // ==== //
73
87 virtual size_t read(size_t offset, size_t size, void* dst);
88
89 // ===== //
90 // WRITE //
91 // ===== //
92
106 virtual size_t write(size_t offset, size_t size, const void* src);
107
108 // ====== //
109 // RESIZE //
110 // ====== //
111
119 virtual void resize(size_t newSize);
120
121 // ============= //
122 // MEMORY_ACCESS //
123 // ============= //
124
132 virtual void* buffer();
133
141 virtual const void* bufferReadOnly() const;
142
150 virtual size_t bufferSize();
151};
152
153} // namespace iolink