![]() |
VRS
A file format for sensor data.
|
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) |
FileDelegator * | getExtraDelegator (const FileSpec &fileSpec) |
FileDelegator * | getExtraDelegator (const string &extraName, const string &extraValue) |
void | registerFileHandler (unique_ptr< FileHandler > &&fileHandler) |
Delegators operating on FileSpec.fileHandlerName. | |
void | unregisterFileHandler (const string &fileHandlerName) |
unique_ptr< FileHandler > | getFileHandler (const string &name) |
FileDelegator * | getFileDelegator (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 FileHandlerFactory & | getInstance () |
A factory system for FileHandlers, allowing the runtime registration & usage of custom FileHandler implementations.
|
virtual |
Use different strategies to determine which FileHandler should be used to open the file path.
path | a path or other form of identification for a file. |
outNewDelegate | If 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. |
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
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.
|
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.
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