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

jojo - new concept

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/trunk
SVN Revision: 1487
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 252eab5a
/*! \file sffistream.cc
* \brief SFF input stream (implementation)
*
* ----------------------------------------------------------------------------
*
* $Id: sffistream.cc,v 1.1 2004-02-14 15:21:20 tforb Exp $
* \author Thomas Forbriger
* \date 10/02/2004
*
* SFF input stream (implementation)
*
* Copyright (c) 2004 by Thomas Forbriger (BFO Schiltach)
*
* REVISIONS and CHANGES
* - 10/02/2004 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define TF_SFFISTREAM_CC_VERSION \
"TF_SFFISTREAM_CC V1.0 "
#define TF_SFFISTREAM_CC_CVSID \
"$Id: sffistream.cc,v 1.1 2004-02-14 15:21:20 tforb Exp $"
#include <sffistream.h>
namespace tf {
}
/* ----- END OF sffistream.cc ----- */
/*! \file sffistream.h
* \brief SFF input stream (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id: sffistream.h,v 1.1 2004-02-14 15:21:21 tforb Exp $
* \author Thomas Forbriger
* \date 10/02/2004
*
* SFF input stream (prototypes)
*
* Copyright (c) 2004 by Thomas Forbriger (BFO Schiltach)
*
* REVISIONS and CHANGES
* - 10/02/2004 V1.0 Thomas Forbriger
*
* ============================================================================
*/
// include guard
#ifndef TF_SFFISTREAM_H_VERSION
#define TF_SFFISTREAM_H_VERSION \
"TF_SFFISTREAM_H V1.0 "
#define TF_SFFISTREAM_H_CVSID \
"$Id: sffistream.h,v 1.1 2004-02-14 15:21:21 tforb Exp $"
namespace tf {
}
#endif // TF_SFFISTREAM_H_VERSION (includeguard)
/* ----- END OF sffistream.h ----- */
/*! \file sffostream.cc
* \brief SFF output stream (implementation)
*
* ----------------------------------------------------------------------------
*
* $Id: sffostream.cc,v 1.1 2004-02-14 15:21:21 tforb Exp $
* \author Thomas Forbriger
* \date 10/02/2004
*
* SFF output stream (implementation)
*
* Copyright (c) 2004 by Thomas Forbriger (BFO Schiltach)
*
* REVISIONS and CHANGES
* - 10/02/2004 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define TF_SFFOSTREAM_CC_VERSION \
"TF_SFFOSTREAM_CC V1.0 "
#define TF_SFFOSTREAM_CC_CVSID \
"$Id: sffostream.cc,v 1.1 2004-02-14 15:21:21 tforb Exp $"
#include <sffostream.h>
namespace sff {
namespace helper {
ostream_manager::ostream_manager(std::ostream& os):
Mos(os),
Mlast(false), Mfileheaderwritten(false),
Mfilefreedefined(false),
Mnormmode(NM_maxdyn) { }
void ostream_manager::setfileheader(const FileHeader& fh)
{
Mfileheader=fh;
Mfilefreedefined=true;
}
void ostream_manager::settraceheader(const TraceHeader& th)
{
Mtraceheader=th;
}
void ostream_manager::setinfo(const INFO& info)
{
Mtraceheader.setinfo(info);
}
void ostream_manager::setwid2(const WID2& wid2)
{
Mtraceheader.setwid2(wid2);
}
void ostream_manager::setsrce(const SRCE& srce)
{
Mfileheader.setsrce(srce);
}
void ostream_manager::setfree(const FREE& free)
{
if (Mfilefreedefined)
{
Mtraceheader.setfree(free);
}
else
{
Mfileheader.setfree(free);
Mfilefreedefined=true;
}
}
void ostream_manager::setnormmode(const Enormmode& normmode)
{
Mnormmode=normmode;
}
void ostream_manager::nextislast()
{
Mlast=true;
}
void ostream_manager::clearlast()
{
Mlast=false;
}
const TraceHeader& ostream_manager::traceheader() const
{
Mtraceheader.setlast(Mlast);
return(Mtraceheader);
}
const FileHeader& ostream_manager::fileheader() const
{
return(Mfileheader);
}
const Enormmode& ostream_manager::normmode() const
{
return(Mnormmode);
}
void ostream_manager::flushheader()
{
if (!Mfileheaderwritten)
{
Mos << Mfileheader;
Mfileheaderwritten=true;
}
}
} // namespace helper
} // namespace sff
/* ----- END OF sffostream.cc ----- */
/*! \file sffostream.h
* \brief SFF output stream (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id: sffostream.h,v 1.1 2004-02-14 15:21:22 tforb Exp $
* \author Thomas Forbriger
* \date 10/02/2004
*
* SFF output stream (prototypes)
*
* Copyright (c) 2004 by Thomas Forbriger (BFO Schiltach)
*
* REVISIONS and CHANGES
* - 10/02/2004 V1.0 Thomas Forbriger
*
* ============================================================================
*/
// include guard
#ifndef TF_SFFOSTREAM_H_VERSION
#define TF_SFFOSTREAM_H_VERSION \
"TF_SFFOSTREAM_H V1.0 "
#define TF_SFFOSTREAM_H_CVSID \
"$Id: sffostream.h,v 1.1 2004-02-14 15:21:22 tforb Exp $"
#include<sffxx.h>
#include<iostream>
namespace sff {
namespace helper {
class ostream_manager {
public:
ostream_manager(std::ostream& os);
void setfileheader(const FileHeader&);
void settraceheader(const TraceHeader&);
void setinfo(const INFO&);
void setwid2(const WID2&);
void setsrce(const SRCE&);
void setfree(const FREE&);
void setnormmode(const Enormmode&);
void nextislast();
void clearlast();
const TraceHeader& traceheader() const;
const FileHeader& fileheader() const;
const Enormmode& normmode() const;
protected:
void flushheader();
std::ostream& Mos;
private:
FileHeader Mfileheader;
mutable TraceHeader Mtraceheader;
bool Mlast;
bool Mfileheaderwritten;
bool Mfilefreedefined;
Enormmode Mnormmode;
}; // class ostream_manager
} // namespace helper
template<class C>
class SFFostream: public helper::ostream_manager {
public:
typedef C Tseries;
typedef typename C::Tcoc Tcseries;
typedef helper::ostream_manager Tbase;
SFFostream(std::ostream& os):
Tbase(os), Mhasseries(false) { }
~SFFostream()
{
if (!Mhasseries) throw
Terror("ERROR (~SFFostream): no waveform!");
this->nextislast();
write();
}
void setseries(const Tcseries& series)
{
if (Mhasseries) { write(); }
Mseries=series;
Mhasseries=true;
}
private:
void write()
{
this->flushheader();
Mos << OutputWaveform<Tseries>(Mseries,
this->traceheader(),
this->normmode());
Mhasseries=false;
}
Tcseries Mseries;
bool Mhasseries;
}; // class SFFostream
template<class C>
SFFostream<C>& operator<<(SFFostream<C>& os, const typename C::Tcoc& c)
{ os.setseries(c); return(os); }
template<class C>
SFFostream<C>& operator<<(SFFostream<C>& os, const WID2& wid2)
{ os.setwid2(wid2); return(os); }
template<class C>
SFFostream<C>& operator<<(SFFostream<C>& os, const INFO& info)
{ os.setinfo(info); return(os); }
template<class C>
SFFostream<C>& operator<<(SFFostream<C>& os, const FREE& free)
{ os.setfree(free); return(os); }
template<class C>
SFFostream<C>& operator<<(SFFostream<C>& os, const SRCE& srce)
{ os.setsrce(srce); return(os); }
template<class C>
SFFostream<C>& operator<<(SFFostream<C>& os, const FileHeader& fh)
{ os.setfileheader(fh); return(os); }
template<class C>
SFFostream<C>& operator<<(SFFostream<C>& os, const TraceHeader& th)
{ os.settraceheader(th); return(os); }
} // namespace sff
#endif // TF_SFFOSTREAM_H_VERSION (includeguard)
/* ----- END OF sffostream.h ----- */
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