| IOLink 1.11.0

Loading...
Searching...
No Matches
RandomAccessProvider.h
1#pragma once
2
3#include <iolink/IOLinkAPI.h>
4#include <iolink/storage/RandomAccess.h>
5
6#include <memory>
7
8 namespace iolink
9{
10
14 class IOLINK_INTERFACE_API RandomAccessProvider
15{
16 public:
20 inline static bool isRandomAccess(std::shared_ptr<DataAccess> randomAccess) noexcept
21 {
22 return (dynamic_cast<const RandomAccess*>(randomAccess.get()) != nullptr);
23 }
24
30 inline static std::shared_ptr<RandomAccess> toRandom(std::shared_ptr<DataAccess> accessor) noexcept
31 {
32 return std::dynamic_pointer_cast<RandomAccess>(accessor);
33 }
34};
35
36} // end namespace iolink
iolink::RandomAccess
Interface representing a generic array-like accessor.
Definition RandomAccess.h:46
iolink::RandomAccessProvider
Utility class to check and convert a DataAccess into a RandomAccess.
Definition RandomAccessProvider.h:15
iolink::RandomAccessProvider::toRandom
static std::shared_ptr< RandomAccess > toRandom(std::shared_ptr< DataAccess > accessor) noexcept
Return the RandomAccess interface if the accessor supports it.
Definition RandomAccessProvider.h:30
iolink::RandomAccessProvider::isRandomAccess
static bool isRandomAccess(std::shared_ptr< DataAccess > randomAccess) noexcept
Checks if DataAccess supports RandomAccess interface.
Definition RandomAccessProvider.h:20
iolink
All IOLink symbols are enclosed in this namespace.
Definition ArrayX.h:8