soma-io
5.1.2
|
Low-level object IO reader specialized for a specific format. More...
#include <soma-io/reader/formatreader.h>
Public Member Functions | |
virtual | ~FormatReader () |
virtual void | setupAndRead (T &obj, carto::rc_ptr< DataSourceInfo > dsi, const AllocatorContext &context, carto::Object options) |
Full reading procedure, for an already existing object. More... | |
virtual T * | createAndRead (carto::rc_ptr< DataSourceInfo > dsi, const AllocatorContext &context, carto::Object options) |
Factory mode: creates an object and reads it. More... | |
virtual void | read (T &obj, carto::rc_ptr< DataSourceInfo > dsi, const AllocatorContext &context, carto::Object options) |
Reads part or all of the object obj . More... | |
virtual FormatReader< T > * | clone () const =0 |
Duplicate the FormatReader. More... | |
virtual std::string | formatID () const =0 |
Format identifier (abstract). More... | |
virtual carto::rc_ptr< DataSourceInfo > | checkDataSourceInfo (carto::rc_ptr< DataSourceInfo > dsi, carto::Object options) |
Checks that dsi has been identified with the matching format checker. More... | |
virtual T * | create (carto::Object header, const AllocatorContext &context, carto::Object options) |
create the object to be read, bind the allocation context. More... | |
virtual void | setup (T &obj, carto::Object header, const AllocatorContext &context, carto::Object options) |
setup an existing object (for resizing or reallocation for instance). More... | |
Low-level object IO reader specialized for a specific format.
To invoque such a format-specific reader, information about the source is supposed to be already read, this is to say: the object header has already been read (using DataSourceInfo).
This is a low-level format reader, which is not intended to be used alone: Reader will use it to achieve appropriate decoding, allocation, and reading.
The job of a reader can be decomposed into several steps:
reading of the data, or of a part of it, which can be done on demand, directly via the DataSource once it is setup and plugged
Definition at line 84 of file formatreader.h.
|
virtual |
Definition at line 61 of file formatreader_d.h.
|
virtual |
Checks that dsi has been identified with the matching format checker.
If not, instantiate a new DataSourceInfo and return it. If yes, the returned DataSourceInfo will be the input one. This method is called automatically from createAndRead() or setupAndRead().
Definition at line 118 of file formatreader_d.h.
References soma::DataSourceInfoLoader::check(), carto::Object::isNone(), localMsg, and carto::Object::value().
|
pure virtual |
Duplicate the FormatReader.
Some FormatReader can contain data describing the data source or storage buffer, so must be cloned for each read. Note that, for now, the cloned instance does not need to have the same bound internal data, since it is cloned precisely to work on a different source/buffer. It just needs to be another instance of the same exact type.
Implemented in soma::XMLFormatReader, soma::PythonFormatReader, and soma::JsonFormatReader.
Referenced by soma::Reader< T >::read().
|
virtual |
create the object to be read, bind the allocation context.
Either create() or setup() will be called, depending if we are working on an existing object or have to allocate a new one. The default implementations just calls Creator<T>::create().
Definition at line 140 of file formatreader_d.h.
References soma::Creator< T >::create(), and localMsg.
|
virtual |
Factory mode: creates an object and reads it.
The returned object belongs to the calling layer and may be deleted by the standard delete
Reimplemented in soma::XMLFormatReader, soma::PythonFormatReader, and soma::JsonFormatReader.
Definition at line 83 of file formatreader_d.h.
|
pure virtual |
Format identifier (abstract).
Used to match checker and reader
Implemented in soma::XMLFormatReader, soma::PythonFormatReader, and soma::JsonFormatReader.
|
virtual |
Reads part or all of the object obj
.
This read() method should be called after everything is setup and bound For objects supporting allocators, context
should be the same as the context bound to the object, and reading is just a matter of calling the read methods of the DataSource bound to the context.
obj | object to read into |
dsi | DataSourceInfo containing pre-computed header, data source list and capabilities. |
options | may specify a sub-object for partial reading |
Definition at line 106 of file formatreader_d.h.
|
virtual |
setup an existing object (for resizing or reallocation for instance).
Either create() or setup() will be called, depending if we are working on an existing object or have to allocate a new one. The default implementations just calls Creator<T>::create().
Definition at line 149 of file formatreader_d.h.
|
virtual |
Full reading procedure, for an already existing object.
Definition at line 69 of file formatreader_d.h.
References soma::AllocatorContext::accessMode(), localMsg, and soma::AllocatorContext::useFactor().