IOLink  IOL_v1.1.0_release
RandomAccessFactory.h
1 #pragma once
2 
3 #include <map>
4 #include <memory>
5 
6 #include <iolink/IOLinkAPI.h>
7 #include <iolink/Uri.h>
8 #include <iolink/storage/HTTPHeaders.h>
9 #include <iolink/storage/RandomAccess.h>
10 #include <iolink/storage/StreamAccess.h>
11 
12 namespace iolink
13 {
14 
18 class IOLINK_API RandomAccessFactory
19 {
20 public:
21  RandomAccessFactory() = delete;
22  RandomAccessFactory(const RandomAccessFactory& other) = delete; // copy constructor
23  RandomAccessFactory(RandomAccessFactory&& other) = delete; // move constructor
24  RandomAccessFactory& operator=(const RandomAccessFactory& other) = delete; // copy assignment
25  RandomAccessFactory& operator=(RandomAccessFactory&& other) = delete; // move assignment
26 
30  static std::shared_ptr<RandomAccess> allocate(size_t size);
31 
36  static std::shared_ptr<RandomAccess> copyInMemory(std::shared_ptr<RandomAccess> randomAccess);
37 
46  static std::shared_ptr<RandomAccess> mapFile(const std::string& filePath);
47 
54  static std::shared_ptr<RandomAccess> fromBuffer(void* buffer, size_t size);
55 
62  static std::shared_ptr<RandomAccess> openURIRead(const Uri& uri);
63 
72  static std::shared_ptr<RandomAccess> openHTTPRead(const Uri& uri,
73  const std::string& method,
74  const HTTPHeaders& headers);
75 
84  static std::shared_ptr<RandomAccess> extractRegion(std::shared_ptr<RandomAccess> src, size_t offset);
85 
95  static std::shared_ptr<RandomAccess> extractRegion(std::shared_ptr<RandomAccess> src, size_t offset, size_t size);
96 
100  static std::shared_ptr<RandomAccess> fromStream(std::shared_ptr<StreamAccess> stream);
101 };
102 
103 } // end namespace iolink