IOLink IOL_v1.8.0_release
Loading...
Searching...
No Matches
ImageView.h
1#pragma once
2
3#include <memory>
4
5#include <iolink/DataType.h>
6#include <iolink/FlagSet.h>
7#include <iolink/IOLinkAPI.h>
8#include <iolink/Indexer.h>
9#include <iolink/RegionX.h>
10#include <iolink/VectorX.h>
11#include <iolink/metadata/MetadataNode.h>
12#include <iolink/property/ImageProperties.h>
13#include <iolink/view/ParallelAccessExtension.h>
14#include <iolink/view/TilingInfoExtension.h>
15#include <iolink/view/View.h>
16
17namespace iolink
18{
19
24{
25 // Flags
26 READ = 0x1,
27 WRITE = 0x2,
28 RESHAPE = 0x4,
29 MEMORY_ACCESS = 0x8,
30
31 // Combinations
32 READ_WRITE = 0x3,
33};
34
35extern template class IOLINK_API_IMPORT FlagSet<ImageCapability>;
36
41
42// Define bitwise operators for ImageCapability
43IOLINK_DEFINE_ENUM_BITWISE_OPERATORS(ImageCapability)
44
45
69class IOLINK_API ImageView : public View
70{
71
72public:
73 virtual ~ImageView() = default;
74
78 inline size_t dimensionCount() { return this->shape().size(); }
79
83 inline bool support(ImageCapabilitySet flags) { return this->capabilities().has(flags); }
84
88 virtual ImageCapabilitySet capabilities() const = 0;
89
101 virtual const VectorXu64& shape() = 0;
102
106 virtual DataType dataType() = 0;
107
111 virtual std::shared_ptr<const ImageProperties> properties() = 0;
112
116 std::string toString() const;
117
118 // ==== //
119 // READ //
120 // ==== //
121
129 virtual std::shared_ptr<const MetadataNode> metadata() const;
130
142 virtual void read(const VectorXu64& index, void* dst);
143
154 virtual void readRegion(const RegionXu64& region, void* dst);
155
156 // Shortcuts
157
164
171
178
185
191 std::string spatialUnit();
192
199
205 size_t bitDepth();
206
212 bool hasAlpha();
213
220
221 // ===== //
222 // WRITE //
223 // ===== //
224
232 virtual void setProperties(std::shared_ptr<const ImageProperties> properties);
233
241 virtual void setMetadata(std::shared_ptr<MetadataNode> metadata);
242
254 virtual void write(const VectorXu64& index, const void* src);
255
266 virtual void writeRegion(const RegionXu64& region, const void* src);
267
268 // Shortcuts
269
275 void setImageInterpretation(const ImageInterpretation interpretation);
276
283
289 void setSpatialOrigin(const Vector3d& origin);
290
296 void setSpatialSpacing(const Vector3d& spacing);
297
303 void setSpatialUnit(const std::string& unit);
304
311
317 void setBitDepth(size_t bitDepth);
318
324 void setAlpha(bool value);
325
331 void setValueRange(const Vector2d& range);
332
333 // ======= //
334 // RESHAPE //
335 // ======= //
336
349 virtual void reshape(const VectorXu64& shape, DataType dataType);
350
351 // ============= //
352 // MEMORY_ACCESS //
353 // ============= //
354
362 virtual const Indexer& indexer();
363
371 virtual void* buffer();
372
380 virtual const void* bufferReadOnly() const;
381
389 virtual size_t bufferSize();
390
391 // ========== //
392 // Extensions //
393 // ========== //
394
398 std::shared_ptr<TilingInfoExtension> tilingInfo();
399
403 std::shared_ptr<ParallelAccessExtension> parallelAccess();
404};
405
406} // namespace iolink