Commit a9f85996 authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

SU reading module compiles

This is a legacy commit from before 2015-03-01.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/branches/libdatrwxx.su
SVN Revision: 3468
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 4e5234ea
......@@ -23,7 +23,7 @@
# ----
#
# Other libraries that are required to compile libdatrwxx:
# libaff, libgsexx, libtime, libsffxx
# libaff, libgsexx, libtime++, libsffxx
#
# REVISIONS and CHANGES
# 30/03/2004 V1.0 Thomas Forbriger
......
......@@ -219,7 +219,10 @@ constructor datrw::ianystream::ianystream().
\section sec_howtoworks_go So, what happens when you are up to read a file?
\subsection subsec_howtoworks_fileheader Reading the file header
You create an instance of the input stream class by passing an input stream
You create an instance of the input stream class by passing an C++ istream
(isually a std::ifstream opened with the appropriate open mode as indicated by
\ref openmode of the libdatrwxx input stream class, like
datrw::isffstream::openmode)
from which data should be read to the constructor of the stream class.
The constructor of the input stream starts reading the file by parsing the
\em file \em header.
......
......@@ -67,14 +67,12 @@ namespace datrw {
virtual ~isustream() { }
virtual Tdseries dseries();
virtual Tfseries fseries();
virtual Tiseries iseries();
virtual void skipseries();
static void help(std::ostream& os=std::cout);
static const std::ios_base::openmode openmode;
private:
void readnextheader();
void readheader();
bool Mdebug;
sff::SRCE Msrce;
datrw::su::SUheader Mnextheader;
}; // class isacstream
......
......@@ -62,6 +62,7 @@ namespace datrw {
DATRW_assert(is.good(),
"ERROR (isustream::isustream): input stream is bad");
Mnextheader.read(is);
this->setsrce(Mnextheader.srce());
}
/*----------------------------------------------------------------------*/
......@@ -75,34 +76,38 @@ namespace datrw {
Tfseries isustream::fseries()
{
//this->readheader();
//return(datrw::su::read_su_data(this->Mis, this->wid2().nsamples));
DATRW_abort("ERROR: not implemented");
Tfseries series(Mnextheader.Mheader.ns);
this->readheader();
char *ipointer=reinterpret_cast<char *>(series.pointer());
DATRW_Xassert(Mis.read(ipointer, series.size()*sizeof(float)),
"ERROR (isustream::fseries): reading SU samples",
::datrw::su::SUReadException);
return(Tfseries(0));
} // Tiseries isustream::fseries()
/*----------------------------------------------------------------------*/
/*
Tiseries isustream::iseries()
{
return(datrw::util::convert<Tfseries, Tiseries>(this->fseries()));
} // Tiseries isustream::iseries()
*/
/*----------------------------------------------------------------------*/
void isustream::skipseries()
{
Tfseries s=this->fseries();
} // void isustream::skipseries()
/*----------------------------------------------------------------------*/
/*
void isustream::readheader()
{
DATRW_assert(this->good(),
"ERROR (isustream::readheader): reached end of file");
this->newtrace();
this->setwid2(Mnextheader.wid2());
this->setinfo(Mnextheader.info());
try {
Mnextheader.read(Mis);
} catch (datrw::su::SUReadException)
{
this->setlast();
}
} // void isustream::readheader()
*/
/*----------------------------------------------------------------------*/
......
......@@ -51,8 +51,9 @@ namespace datrw {
void SUheader::read(std::istream& is)
{
char *ipointer=reinterpret_cast<char *>(&Mheader);
DATRW_assert(is.read(ipointer, sizeof(TraceHeaderStruct)),
"ERROR (SUheader::read): reading SU header");
DATRW_Xassert(is.read(ipointer, sizeof(TraceHeaderStruct)),
"ERROR (SUheader::read): reading SU header",
SUReadException);
} // void SUheader::read(std::istream& is)
/*----------------------------------------------------------------------*/
......
......@@ -43,6 +43,7 @@
#include<iostream>
#include<datrwxx/suheaderstruct.h>
#include<datrwxx/error.h>
#include<sffxx.h>
#include<libtime++.h>
......@@ -63,6 +64,21 @@ namespace datrw {
*/
namespace su {
class SUReadException: public datrw::Exception
{
public:
//! Create with message, failed assertion, and code position
SUReadException(const char* message,
const char* file,
const int& line,
const char* condition)
: ::datrw::Exception(message, file, line, condition) { }
//! provide explicit virtual destructor
virtual ~SUReadException() { }
}; // class SUReadException
/*----------------------------------------------------------------------*/
class SUheader {
public:
//! constructor
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment