/*! \file sff.cc * \brief wrapper around SFF output stream (implementation) * * ---------------------------------------------------------------------------- * * $Id: sff.cc,v 1.7 2010-04-30 19:59:35 tforb Exp $ * \author Thomas Forbriger * \date 11/04/2006 * * wrapper around SFF output stream (implementation) * * Copyright (c) 2006 by Thomas Forbriger (BFO Schiltach) * * ---- * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ---- * * * REVISIONS and CHANGES * - 11/04/2006 V1.0 Thomas Forbriger * * ============================================================================ */ #define DATWRITE_SFF_CC_VERSION \ "DATWRITE_SFF_CC V1.0 " #define DATWRITE_SFF_CC_CVSID \ "$Id: sff.cc,v 1.7 2010-04-30 19:59:35 tforb Exp $" #include #include #include namespace datwrite { osffstream::osffstream(std::ostream& os, const bool& debug): Tbase(os), Mdebug(debug), Mwid2iswaiting(false), Mfreeiswaiting(false), Minfoiswaiting(false), Mnormmode(::sff::NM_maxdyn) { Mdebug=debug; DATWRITE_debug(Mdebug, "osffstream::osffstream", "new instance established"); } // osffstream::osffstream(std::ostream& os, const bool& debug) /*----------------------------------------------------------------------*/ void osffstream::help(std::ostream& os) { os << "This module writes standard SFF data." << std::endl; } // void osffstream::help(std::ostream& os=std::cout) /*----------------------------------------------------------------------*/ void osffstream::writefileheader() { DATWRITE_debug(Mdebug, "osffstream::writefileheader", "write file header to file"); ::sff::FileHeader fileheader; if (Msrceset) { fileheader.setsrce(Msrce); } if (Mfreeset) { fileheader.setfree(Mfree); } Mos << fileheader; } // void osffstream::writefileheader() /*----------------------------------------------------------------------*/ void osffstream::writetrace(const Tdseries& series) { DATWRITE_debug(Mdebug, "osffstream::writefileheader", "write series of type double to file"); this->flushwaitingtrace(); Mserieswaiting=datwrite::util::seriesreservoir(series); } // void osffstream::writetrace(const Tdseries& series) /*----------------------------------------------------------------------*/ void osffstream::writetrace(const Tfseries& series) { DATWRITE_debug(Mdebug, "osffstream::writefileheader", "write series of type float to file"); this->flushwaitingtrace(); Mserieswaiting=datwrite::util::seriesreservoir(series); } // void osffstream::writetrace(const Tfseries& series) /*----------------------------------------------------------------------*/ void osffstream::writetrace(const Tiseries& series) { DATWRITE_debug(Mdebug, "osffstream::writefileheader", "write series of type integer to file"); this->flushwaitingtrace(); Mserieswaiting=datwrite::util::seriesreservoir(series); } // void osffstream::writetrace(const Tiseries& series) /*----------------------------------------------------------------------*/ void osffstream::flushwaitingtrace(const bool& last) { DATWRITE_debug(Mdebug, "osffstream::flushwaitingtrace", "flush previous trace data to file"); // flush previous trace if (Mwid2iswaiting) { // prepare trace header ::sff::TraceHeader traceheader(Mwid2waiting, last); if (Mfreeiswaiting) { traceheader.setfree(Mfreewaiting); } if (Minfoiswaiting) { traceheader.setinfo(Minfowaiting); } datwrite::sff::writesfftrace(Mos, traceheader, Mserieswaiting, Mnormmode); } else { DATWRITE_assert((!last), "file is to be closed and no data was written"); } // check for current trace headers and store them if (!last) { DATWRITE_assert(Mwid2set, "missing trace header data"); Mwid2iswaiting=true; Mwid2waiting=Mwid2; Mfreeiswaiting=false; if (Mfreeset) { Mfreeiswaiting=true; Mfreewaiting=Mfree; } Minfoiswaiting=false; if (Mfreeset) { Minfoiswaiting=true; Minfowaiting=Minfo; } } } /*======================================================================*/ ogsestream::ogsestream(std::ostream& os, const bool& debug): Tbase(os, debug) { Mnormmode=::sff::NM_one; DATWRITE_debug(Mdebug, "ogsestream::ogsestream", "new instance established"); } // ogsestream::ogsestream(std::ostream& os, const bool& debug) /*----------------------------------------------------------------------*/ void ogsestream::help(std::ostream& os) { os << "This module writes standard GSE data." << std::endl; os << "Essentially SFF data is written but without normalising" << std::endl; os << "them. Notice that floating point data will by truncated to" << std::endl; os << "integers." << std::endl; } // void ogsestream::help(std::ostream& os=std::cout) } // namespace datwrite /* ----- END OF sff.cc ----- */