vitrio 0.1.4
High-throughput image I/O for Cryo-Electron Microscopy (CryoEM)
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
vitrio::image_file_write_format_selector Class Referencefinal

Holds the image formats that can be written, selects the most suitable of them for a file, and creates the file with it. More...

#include <vitrio/image_file_write_format_selector.hpp>

Public Member Functions

 image_file_write_format_selector ()
 Construct a selector with no formats.
 
 image_file_write_format_selector (const image_file_write_format_selector &other)=delete
 
 image_file_write_format_selector (image_file_write_format_selector &&other)=delete
 
image_file_write_format_selector & operator= (const image_file_write_format_selector &other)=delete
 
image_file_write_format_selector & operator= (image_file_write_format_selector &&other)=delete
 
void register_builtin_formats ()
 Register the formats bundled with the library.
 
bool register_format (std::unique_ptr< image_file_write_format > format)
 Register a new image write format.
 
std::shared_ptr< image_writer > open (const std::string &path, const image_descriptor &descriptor, const image_metadata &metadata) const
 Create a file with the most suitable format.
 
const image_file_write_format * get_most_suitable_format (const image_file_probe &probe) const
 Get the format that would create a file, without creating it.
 

Static Public Member Functions

static const std::shared_ptr< image_file_write_format_selector > & get_shared ()
 Get the selector every use may share.
 

Detailed Description

Holds the image formats that can be written, selects the most suitable of them for a file, and creates the file with it.

register_builtin_formats adds the formats bundled with the library, and register_format adds any other. get_shared is a selector that already holds the bundled ones.

Thread safety
Every method may be called concurrently.
See also
image_file_read_format_selector

Member Function Documentation

◆ get_most_suitable_format()

const image_file_write_format * vitrio::image_file_write_format_selector::get_most_suitable_format ( const image_file_probe &  probe) const

Get the format that would create a file, without creating it.

Parameters
probeThe file under consideration.
Returns
const image_file_write_format* The most suitable format, or nullptr when none recognizes probe.

◆ get_shared()

static const std::shared_ptr< image_file_write_format_selector > & vitrio::image_file_write_format_selector::get_shared ( )
static

Get the selector every use may share.

It holds the formats bundled with the library. A format registered on it is seen by everyone that shares it.

Returns
const std::shared_ptr<image_file_write_format_selector>& The selector. Never null.

◆ open()

std::shared_ptr< image_writer > vitrio::image_file_write_format_selector::open ( const std::string &  path,
const image_descriptor &  descriptor,
const image_metadata &  metadata 
) const

Create a file with the most suitable format.

The file named by path need not exist, in which case the choice rests on its extension. Any file already there is replaced.

Parameters
pathPath to the file to create.
descriptorWhat the file holds.
metadataHow its samples map onto physical space.
Returns
std::shared_ptr<image_writer> The opened writer, never null.
Exceptions
unsupported_operation_errorIf no registered format recognizes the file, or if the chosen one can not represent the requested file.
image_file_errorIf the file could not be created.

◆ register_format()

bool vitrio::image_file_write_format_selector::register_format ( std::unique_ptr< image_file_write_format >  format)

Register a new image write format.

Parameters
formatThe format to be registered.
Returns
true The format was successfully registered.
false The format was null.

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