soma-io
5.1.2
|
Generic reader for every format of Cartograph object. More...
#include <soma-io/io/reader.h>
Public Member Functions | |
Reader () | |
Reader (const std::string &filename) | |
Reader (carto::rc_ptr< DataSource > ds) | |
Reader (carto::rc_ptr< DataSourceInfo > dsi) | |
Reader (std::istream &stream) | |
virtual | ~Reader () |
virtual bool | read (T &obj, carto::Object header=carto::none(), int passbegin=1, int passend=4) |
Finds the correct format and reads the object. More... | |
virtual T * | read (carto::Object header=carto::none(), int passbegin=1, int passend=4) |
Creates and reads an object. More... | |
const carto::rc_ptr< DataSourceInfo > & | dataSourceInfo () const |
carto::rc_ptr< DataSourceInfo > & | dataSourceInfo () |
void | setAllocatorContext (const AllocatorContext &ac) |
const AllocatorContext & | allocatorContext () const |
void | setOptions (carto::Object options) |
carto::Object | options () const |
carto::Object & | options () |
const carto::rc_ptr< DataSource > | dataSource () const |
carto::rc_ptr< DataSource > | dataSource () |
void | attach (carto::rc_ptr< DataSource > ds) |
void | attach (const std::string &filename, offset_t offset=0) |
void | attach (std::istream &stream) |
void | flush () |
void | close () |
Static Public Member Functions | |
static std::string | extension (const std::string &filename) |
Protected Attributes | |
carto::rc_ptr< DataSourceInfo > | _datasourceinfo |
AllocatorContext | _alloccontext |
carto::Object | _options |
Generic reader for every format of Cartograph object.
Still a template class, the data type must be switched at upper-level (see DataSourceInfoLoader or ReaderAlgorithm).
Generic readers offer a plug-in mechanism to allow new formats to be registered.
It uses at lower level specific readers of each object type (Volume, Meshes, Buckets, Textures) and even lower, specific reader of each format (GIS, SPM).
See IO system general explanations on how to use Reader and Writer classes.
The standard cartodata library includes a set of already compiled formats, using a FormatDictionary to provide a common link between Reader and Writer, see FormatDictionary for a list.
If you need to use other types, you'll have to include soma-io/io/reader_d.h
in order to have the template functions definitions, soma-io/io/reader.h
is only the class declarations. In addition, you may want to specialize the registerBaseFormats() functions of the FormatDictionary classes.
soma::Reader< T >::Reader |
Definition at line 70 of file reader_d.h.
soma::Reader< T >::Reader | ( | const std::string & | filename | ) |
Definition at line 85 of file reader_d.h.
soma::Reader< T >::Reader | ( | carto::rc_ptr< DataSource > | ds | ) |
Definition at line 75 of file reader_d.h.
soma::Reader< T >::Reader | ( | carto::rc_ptr< DataSourceInfo > | dsi | ) |
Definition at line 80 of file reader_d.h.
soma::Reader< T >::Reader | ( | std::istream & | stream | ) |
Definition at line 92 of file reader_d.h.
|
virtual |
Definition at line 99 of file reader_d.h.
const AllocatorContext & soma::Reader< T >::allocatorContext |
Definition at line 113 of file reader_d.h.
void soma::Reader< T >::attach | ( | carto::rc_ptr< DataSource > | ds | ) |
Definition at line 143 of file reader_d.h.
void soma::Reader< T >::attach | ( | const std::string & | filename, |
offset_t | offset = 0 |
||
) |
Definition at line 153 of file reader_d.h.
void soma::Reader< T >::attach | ( | std::istream & | stream | ) |
Definition at line 165 of file reader_d.h.
void soma::Reader< T >::close | ( | void | ) |
Definition at line 205 of file reader_d.h.
carto::rc_ptr< DataSource > soma::Reader< T >::dataSource |
Definition at line 187 of file reader_d.h.
References soma::DataSource::none().
const carto::rc_ptr< DataSource > soma::Reader< T >::dataSource |
Definition at line 177 of file reader_d.h.
References soma::DataSource::none().
|
inline |
Definition at line 126 of file reader.h.
References soma::Reader< T >::_datasourceinfo.
|
inline |
Definition at line 124 of file reader.h.
References soma::Reader< T >::_datasourceinfo.
|
static |
void soma::Reader< T >::flush |
Definition at line 197 of file reader_d.h.
carto::Object & soma::Reader< T >::options |
Definition at line 134 of file reader_d.h.
carto::Object soma::Reader< T >::options |
Definition at line 128 of file reader_d.h.
|
virtual |
Creates and reads an object.
This function differs from the read( T&, ... ) function in the way that it creates the object and does not just fill it. This enables to create sub-classes of T (factory-like behaviour) on types that allow subclasses. The object is created by new
and can be deleted. The default is just to create a T and call the read( T&, ... ) function, but some specialized low-level readers may behave differently. It is possible to specify which passes to process through passbegin
and passend
.
Definition at line 427 of file reader_d.h.
References soma::DataSourceInfoLoader::check(), soma::FormatReader< T >::clone(), soma::DataSourceList::empty(), carto::FileUtil::extension(), rc_ptr< GenericObject >::get(), soma::DataSourceInfo::header(), carto::Object::isNone(), carto::io_error::keepExceptionPriority(), carto::io_error::launchExcept(), soma::DataSourceInfoLoader::launchException(), soma::DataSourceInfo::list(), localMsg, soma::FormatDictionary< T >::readExtensions(), soma::FormatDictionary< T >::readFormat(), soma::FormatDictionary< T >::readFormats(), carto::toString(), and carto::Object::value().
|
virtual |
Finds the correct format and reads the object.
if format
is specified, this format is tried first, so you can use it as a hint if you already know it (from the DataSourceInfoLoader check ). It is possible to specify which passes to process through passbegin
and passend
.
Definition at line 223 of file reader_d.h.
References soma::DataSourceInfo::capabilities(), soma::DataSourceInfoLoader::check(), soma::FormatReader< T >::clone(), soma::DataSourceList::empty(), carto::FileUtil::extension(), rc_ptr< GenericObject >::get(), soma::DataSourceInfo::header(), carto::Object::isNone(), carto::io_error::keepExceptionPriority(), carto::io_error::launchExcept(), soma::DataSourceInfoLoader::launchException(), soma::DataSourceInfo::list(), localMsg, soma::FormatDictionary< T >::readExtensions(), soma::FormatDictionary< T >::readFormat(), soma::FormatDictionary< T >::readFormats(), soma::DataSourceCapabilities::setMemoryMapping(), carto::toString(), and carto::Object::value().
Referenced by operator>>().
void soma::Reader< T >::setAllocatorContext | ( | const AllocatorContext & | ac | ) |
Definition at line 107 of file reader_d.h.
void soma::Reader< T >::setOptions | ( | carto::Object | options | ) |
Definition at line 122 of file reader_d.h.
|
protected |
|
protected |
Definition at line 168 of file reader.h.
Referenced by soma::Reader< T >::dataSourceInfo().
|
protected |