VRS
A file format for sensor data.
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
vrs::FileHandlerFactory Class Reference

A factory system for FileHandlers, allowing the runtime registration & usage of custom FileHandler implementations. More...

#include <FileHandlerFactory.h>

Public Member Functions

void registerFileDelegator (const string &name, unique_ptr< FileDelegator > &&delegator)
 Delegators operating on FileSpec.fileHandlerName.
 
void unregisterFileDelegator (const string &name)
 
void registerExtraDelegator (const string &extraName, const string &extraValue, unique_ptr< FileDelegator > &&delegator)
 
void unregisterExtraDelegator (const string &extraName, const string &extraValue)
 
FileDelegatorgetExtraDelegator (const FileSpec &fileSpec)
 
FileDelegatorgetExtraDelegator (const string &extraName, const string &extraValue)
 
void registerFileHandler (unique_ptr< FileHandler > &&fileHandler)
 Delegators operating on FileSpec.fileHandlerName.
 
void unregisterFileHandler (const string &fileHandlerName)
 
unique_ptr< FileHandlergetFileHandler (const string &name)
 
FileDelegatorgetFileDelegator (const string &name)
 
virtual int delegateOpen (const string &path, unique_ptr< FileHandler > &outNewDelegate)
 
virtual int delegateOpen (const FileSpec &fileSpec, unique_ptr< FileHandler > &outNewDelegate)
 
virtual int parseUri (FileSpec &inOutFileSpec, size_t colonIndex)
 

Static Public Member Functions

static FileHandlerFactorygetInstance ()
 

Detailed Description

A factory system for FileHandlers, allowing the runtime registration & usage of custom FileHandler implementations.

Member Function Documentation

◆ delegateOpen()

int vrs::FileHandlerFactory::delegateOpen ( const string &  path,
unique_ptr< FileHandler > &  outNewDelegate 
)
virtual

Use different strategies to determine which FileHandler should be used to open the file path.

Parameters
patha path or other form of identification for a file.
outNewDelegateIf provided, might be a fallback FileHandler to use. On success, will be set to the right FileHandler to handle the provided path. On failure, maybe unset.
Returns
A status code, 0 meaning success.

path identification methods: 1) File paths; examples /posix/path/to/file, or C:\\Path\\To\\File 2) URI paths, probably mapped to custom FileHandler implementations registered externally. 3) JSON "paths" containing: storage - name of a registered file handler to use chunks - storage specific references (path, url, ...) to successive chunks of data

{
"storage": "required-name-of-file-handler",
"chunks": [ "chunk_path_1", "chunk2_path_2", ... ],
}

JSON paths are converted into FileSpec objects by FileSpec::fromJson() 4) If all the above methods fail, fall back to opening path as file path.

Method is virtual to enable mock FileHandlerFactories to be created for unit testing.

◆ parseUri()

int vrs::FileHandlerFactory::parseUri ( FileSpec inOutFileSpec,
size_t  colonIndex 
)
virtual

Parsing URIs can be customized by FileHandler and FileDelegators. Note that extra delegators only get the parseUri() callback after parsing is complete, but they can still completely change the FileSpec.

◆ registerExtraDelegator()

void vrs::FileHandlerFactory::registerExtraDelegator ( const string &  extraName,
const string &  extraValue,
unique_ptr< FileDelegator > &&  delegator 
)

Delegators operating on particular key-value pairs of FileSpec.extras so this type of URI can be customized: a_scheme:/my/path?my_unique_name=my_unique_value


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