DATRW++ library: seismic data I/O with multiple formats
|
The base class datrw::idatstream takes care of many organizational issues for you. You are only responsible to provide code which is capable to actually read the data from a file stream.
You have to provide at least a derived stream class like datrw::isffstream, which has to be equipped with:
That's all.
Finally check files readany.h, readany.cc, formats.h, and formats.cc and add appropriate lines to make the new stream visible through the generic interface of datrw::ianystream and the functions presented in readany.h.
The constructor of the input stream initializes its base class datrw::idatstream by passing appropriate parameter values to the constructor datrw::idatstream::idatstream(). The parameters to datrw::idatstream::idatstream() indicate, wheter the stream will provide integer data through virtual member function iseries(), single presicion data through virtual member function fseries(), and/or double presicion data through virtual member function dseries(). Only implement those of the virtual sample access functions, which are supported indeed. For other request the base class will then throw an exception.
For reading from the C++ input stream, the member data datrw::idatstream::Mis is provided to all derived classes.
After initializing the base class, the constructor reads a file header if there is one. The information read from file are passed to the base class through functions
These functions will set flags appropriately and store the information in member data fields, such that they can be provided to the user through the base class interface functions.
The actual reading of traces is controlled by virtual member functions iseries(), fseries(), and dseries(). They all three behave identical and just return series containers of different content type. Only those supported have to be implemented (see above). Each of these functions does the following:
In some cases it is efficient to implement only one of the reading functions with all details and to implement the others by simple type conversion, like datrw::isustream::dseries(). When reading ASCII data the template function datrw::util::readasciidouble() can be useful.
The skipseries() member function is implemented exactly like the trace reading functions. This function has to read the trace header too and must pass the parameters of the trace header to the appropriate member data fields. It just does not allocate memory to read samples. This can make this function slightly more efficient, if the user just wants to scan the data file and check trace header information.