| IOLink 1.11.0

Loading...
Searching...
No Matches
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
37 static std::shared_ptr<RandomAccess> copyInMemory(std::shared_ptr<RandomAccess> randomAccess);
38
47 static std::shared_ptr<RandomAccess> mapFile(const std::string& filePath);
48
55 static std::shared_ptr<RandomAccess> fromBuffer(void* buffer, size_t size);
56
63 static std::shared_ptr<RandomAccess> openURIRead(const Uri& uri);
64
73 static std::shared_ptr<RandomAccess> openHTTPRead(const Uri& uri,
74 const std::string& method,
75 const HTTPHeaders& headers);
76
86 static std::shared_ptr<RandomAccess> extractRegion(std::shared_ptr<RandomAccess> src, size_t offset);
87
98 static std::shared_ptr<RandomAccess> extractRegion(std::shared_ptr<RandomAccess> src, size_t offset, size_t size);
99
104 static std::shared_ptr<RandomAccess> fromStream(std::shared_ptr<StreamAccess> stream);
105};
106
107} // end namespace iolink
iolink::HTTPHeaders
A class used to pass HTTP headers as input of factories methods.
Definition HTTPHeaders.h:16
iolink::RandomAccessFactory
A factory to create RandomAccess instances from various ressources.
Definition RandomAccessFactory.h:19
iolink::RandomAccessFactory::extractRegion
static std::shared_ptr< RandomAccess > extractRegion(std::shared_ptr< RandomAccess > src, size_t offset)
Creates an accessor to a subset of a RandomAccess.
iolink::RandomAccessFactory::openHTTPRead
static std::shared_ptr< RandomAccess > openHTTPRead(const Uri &uri, const std::string &method, const HTTPHeaders &headers)
Create a RandomAccess from given HTTP URI, opening URI in Read Only.
iolink::RandomAccessFactory::fromBuffer
static std::shared_ptr< RandomAccess > fromBuffer(void *buffer, size_t size)
Create a RandomAccess from given memory area.
iolink::RandomAccessFactory::copyInMemory
static std::shared_ptr< RandomAccess > copyInMemory(std::shared_ptr< RandomAccess > randomAccess)
Load given RandomAccess in memory.
iolink::RandomAccessFactory::openURIRead
static std::shared_ptr< RandomAccess > openURIRead(const Uri &uri)
Create a RandomAccess from given URI, opening URI in Read Only.
iolink::RandomAccessFactory::fromStream
static std::shared_ptr< RandomAccess > fromStream(std::shared_ptr< StreamAccess > stream)
Create a RandomAccess that will delegate to a StreamAccess.
iolink::RandomAccessFactory::mapFile
static std::shared_ptr< RandomAccess > mapFile(const std::string &filePath)
Get an accessor from a file mapped in memory.
iolink::RandomAccessFactory::extractRegion
static std::shared_ptr< RandomAccess > extractRegion(std::shared_ptr< RandomAccess > src, size_t offset, size_t size)
Creates an accessor to a subset of a RandomAccess.
iolink::RandomAccessFactory::allocate
static std::shared_ptr< RandomAccess > allocate(size_t size)
Create an in-memory RandomAccess of given size.
iolink::Uri
Class modeling universal resource identifier.
Definition Uri.h:15
iolink
All IOLink symbols are enclosed in this namespace.
Definition ArrayX.h:8