IOLink  IOL_v1.1.0_release
iolink::RandomAccessFactory Class Reference

A factory to create RandomAccess instances from various ressources. More...

#include <iolink/storage/RandomAccessFactory.h>

Public Member Functions

 RandomAccessFactory (const RandomAccessFactory &other)=delete
 
 RandomAccessFactory (RandomAccessFactory &&other)=delete
 
RandomAccessFactoryoperator= (const RandomAccessFactory &other)=delete
 
RandomAccessFactoryoperator= (RandomAccessFactory &&other)=delete
 

Static Public Member Functions

static std::shared_ptr< RandomAccessallocate (size_t size)
 Create an in-memory RandomAccess of given size.
 
static std::shared_ptr< RandomAccesscopyInMemory (std::shared_ptr< RandomAccess > randomAccess)
 Load given RandomAccess in memory. More...
 
static std::shared_ptr< RandomAccessmapFile (const std::string &filePath)
 Get an accessor from a file mapped in memory. More...
 
static std::shared_ptr< RandomAccessfromBuffer (void *buffer, size_t size)
 Create a RandomAccess from given memory area. More...
 
static std::shared_ptr< RandomAccessopenURIRead (const Uri &uri)
 Create a RandomAccess from given URI, opening URI in Read Only. More...
 
static std::shared_ptr< RandomAccessopenHTTPRead (const Uri &uri, const std::string &method, const HTTPHeaders &headers)
 Create a RandomAccess from given HTTP URI, opening URI in Read Only. More...
 
static std::shared_ptr< RandomAccessextractRegion (std::shared_ptr< RandomAccess > src, size_t offset)
 Creates an accessor to a subset of a RandomAccess. More...
 
static std::shared_ptr< RandomAccessextractRegion (std::shared_ptr< RandomAccess > src, size_t offset, size_t size)
 Creates an accessor to a subset of a RandomAccess. More...
 
static std::shared_ptr< RandomAccessfromStream (std::shared_ptr< StreamAccess > stream)
 Create a RandomAccess that will delegate to a StreamAccess.
 

Detailed Description

A factory to create RandomAccess instances from various ressources.

Member Function Documentation

◆ copyInMemory()

static std::shared_ptr<RandomAccess> iolink::RandomAccessFactory::copyInMemory ( std::shared_ptr< RandomAccess randomAccess)
static

Load given RandomAccess in memory.

If storage is already an in-memory RandomAccess, return it (no copy are done).

◆ extractRegion() [1/2]

static std::shared_ptr<RandomAccess> iolink::RandomAccessFactory::extractRegion ( std::shared_ptr< RandomAccess src,
size_t  offset 
)
static

Creates an accessor to a subset of a RandomAccess.

Parameters
srcThe accessor to create the subset from
offsetThe offset from the start of the source accessor
Exceptions
ErrorWhen offset is out of range.

◆ extractRegion() [2/2]

static std::shared_ptr<RandomAccess> iolink::RandomAccessFactory::extractRegion ( std::shared_ptr< RandomAccess src,
size_t  offset,
size_t  size 
)
static

Creates an accessor to a subset of a RandomAccess.

Parameters
srcThe accessor to create the subset from
offsetThe offset from the start of the source accessor
sizeThe size of the subset.
Exceptions
ErrorWhen the subset range is out of the source accessor range.

◆ fromBuffer()

static std::shared_ptr<RandomAccess> iolink::RandomAccessFactory::fromBuffer ( void *  buffer,
size_t  size 
)
static

Create a RandomAccess from given memory area.

Warning
The return DataAccess does not have the ownership of given buffer. You must carefully manage lifetime of each objects.

◆ mapFile()

static std::shared_ptr<RandomAccess> iolink::RandomAccessFactory::mapFile ( const std::string &  filePath)
static

Get an accessor from a file mapped in memory.

Parameters
filePathThe path to the file to map.
Returns
A RandomAccess with read and write capabilities.
Exceptions
ErrorIf the file does not exist already

◆ openHTTPRead()

static std::shared_ptr<RandomAccess> iolink::RandomAccessFactory::openHTTPRead ( const Uri uri,
const std::string &  method,
const HTTPHeaders headers 
)
static

Create a RandomAccess from given HTTP URI, opening URI in Read Only.

Requested HTTP server must support HTTP range requests.

Parameters
uriThe HTTP(S) URI to get.
methodThe HTTP request method.
headersThe HTTP request headers.

◆ openURIRead()

static std::shared_ptr<RandomAccess> iolink::RandomAccessFactory::openURIRead ( const Uri uri)
static

Create a RandomAccess from given URI, opening URI in Read Only.

If the URI scheme is 'file': creates a ReadRandomAccess using StreamAccessFactory::openFileRead(). If the URI scheme is 'http(s)': calls openHTTPRead(), using the GET method and no headers.


The documentation for this class was generated from the following file: