Arbiter  0.0.0
Public Member Functions | Protected Member Functions | List of all members
arbiter::Driver Class Referenceabstract

Base class for interacting with a storage type. More...

#include <arbiter/driver.hpp>

Inheritance diagram for arbiter::Driver:
arbiter::drivers::Fs arbiter::drivers::Http arbiter::drivers::Test arbiter::drivers::Dropbox arbiter::drivers::S3

Public Member Functions

virtual std::string type () const =0
std::string get (std::string path) const
std::unique_ptr< std::string > tryGet (std::string path) const
std::vector< char > getBinary (std::string path) const
std::unique_ptr< std::vector< char > > tryGetBinary (std::string path) const
virtual void put (std::string path, const std::vector< char > &data) const =0
virtual bool isRemote () const
virtual std::unique_ptr< std::size_t > tryGetSize (std::string path) const =0
std::size_t getSize (std::string path) const
void put (std::string path, const std::string &data) const
std::vector< std::string > resolve (std::string path, bool verbose=false) const
 Resolve a possibly globbed path. More...

Protected Member Functions

virtual std::vector< std::string > glob (std::string path, bool verbose) const
 Resolve a wildcard path. More...
virtual bool get (std::string path, std::vector< char > &data) const =0

Detailed Description

Base class for interacting with a storage type.

A Driver handles reading, writing, and possibly globbing from a storage source. It is intended to be overriden by specialized subclasses for each supported storage mechanism.

Derived classes must override Driver::type, Driver::put(std::string, const std::vector<char>&) const, and Driver::get(std::string, std::vector<char>&) const, Driver::getSize(std::string) const - and may optionally override Driver::glob if possible.

HTTP-derived classes should override the PUT and GET versions that accept http::Headers and http::Query parameters instead.

Member Function Documentation

std::string arbiter::Driver::get ( std::string  path) const

Get string data.

virtual bool arbiter::Driver::get ( std::string  path,
std::vector< char > &  data 
) const
protectedpure virtual
pathPath with the type-specifying prefix information stripped.
[out]dataEmpty vector in which to write resulting data.

Implemented in arbiter::drivers::Fs.

std::vector< char > arbiter::Driver::getBinary ( std::string  path) const

Get binary data.

std::size_t arbiter::Driver::getSize ( std::string  path) const

Get the file size in bytes, or throw if it does not exist.

std::vector< std::string > arbiter::Driver::glob ( std::string  path,
bool  verbose 
) const

Resolve a wildcard path.

This operation should return a non-recursive resolution of the files matching the given wildcard path (no directories). With the exception of the filesystem Driver, results should be prefixed with type() + "://".

The default behavior is to throw ArbiterError, so derived classes may optionally override if they can perform this behavior.
pathA string ending with the character *, and with all type-specifying prefix information like http:// or s3:// stripped.
verboseIf true, this function may print out minimal information to indicate that progress is occurring.

Reimplemented in arbiter::drivers::Fs.

virtual bool arbiter::Driver::isRemote ( ) const

True for remote paths, otherwise false. If true, a fs::LocalHandle request will download and write this file to the local filesystem.

Reimplemented in arbiter::drivers::Fs, and arbiter::drivers::Test.

virtual void arbiter::Driver::put ( std::string  path,
const std::vector< char > &  data 
) const
pure virtual

Write data to the given path.

Derived classes must override.
pathPath with the type-specifying prefix information stripped.

Implemented in arbiter::drivers::Fs, and arbiter::drivers::Http.

void arbiter::Driver::put ( std::string  path,
const std::string &  data 
) const

Write string data.

std::vector< std::string > arbiter::Driver::resolve ( std::string  path,
bool  verbose = false 
) const

Resolve a possibly globbed path.

See Arbiter::resolve for details.

std::unique_ptr< std::string > arbiter::Driver::tryGet ( std::string  path) const

Get string data, if available.

std::unique_ptr< std::vector< char > > arbiter::Driver::tryGetBinary ( std::string  path) const

Get binary data, if available.

virtual std::unique_ptr<std::size_t> arbiter::Driver::tryGetSize ( std::string  path) const
pure virtual

Get the file size in bytes, if available.

Implemented in arbiter::drivers::Fs, arbiter::drivers::S3, and arbiter::drivers::Http.

virtual std::string arbiter::Driver::type ( ) const
pure virtual

Returns a string identifying this driver type, which should be unique among all other drivers. Paths that begin with the substring <type>:// will be routed to this driver. For example, fs, s3, or http.

Derived classes must override.

Implemented in arbiter::drivers::Fs, arbiter::drivers::S3, arbiter::drivers::Http, arbiter::drivers::Dropbox, and arbiter::drivers::Test.

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