IOLink  IOL_v1.1.0_release
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