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

proceeding

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: 2981
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 34a321cc
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: datwrite.cc,v 1.4 2010-02-17 22:13:29 tforb Exp $
* $Id: datwrite.cc,v 1.5 2010-02-18 12:16:48 tforb Exp $
* \author Thomas Forbriger
* \date 11/04/2006
*
......@@ -36,48 +36,25 @@
#define DATWRITE_DATWRITE_CC_VERSION \
"TF_DATWRITE_CC V1.0 "
#define DATWRITE_DATWRITE_CC_CVSID \
"$Id: datwrite.cc,v 1.4 2010-02-17 22:13:29 tforb Exp $"
"$Id: datwrite.cc,v 1.5 2010-02-18 12:16:48 tforb Exp $"
#include <datwritexx/datwrite.h>
namespace datwrite {
odatstream::odatstream(std::ostream& os);
Mis(is), Mwid2set(false), Msrceset(false), Minfoset(false),
Mtracefreeset(false), Mfilefreeset(false), Mlast(false),
Mprovidesd(providesd), Mprovidesf(providesf), Mprovidesi(providesi)
Mos(os), Mwid2set(false), Msrceset(false), Minfoset(false),
Mfreeset(false), Mheaderflushed(false)
{
DATWRITE(is.good(), "input stream is not good!");
DATWRITE_assert(os.good(), "output stream is not good!");
}
/*----------------------------------------------------------------------*/
bool odatstream::hasfree() const
void odatstream::setfree(const sff::FREE& free)
{
if (Mwid2set) { return(Mtracefreeset); } else { return(Mfilefreeset); }
}
/*----------------------------------------------------------------------*/
sff::FREE odatstream::free() const
{
if (Mwid2set) { return(Mtracefree); } else { return(Mfilefree); }
}
/*----------------------------------------------------------------------*/
void odatstream::setfilefree(const sff::FREE& free)
{
Mfilefreeset=true;
Mfilefree=free;
}
/*----------------------------------------------------------------------*/
void odatstream::settracefree(const sff::FREE& free)
{
Mtracefreeset=true;
Mtracefree=free;
Mfreeset=true;
Mfree=free;
}
/*----------------------------------------------------------------------*/
......@@ -86,6 +63,7 @@ namespace datwrite {
{
Mwid2set=true;
Mwid2=wid2;
this->flushfileheader();
}
/*----------------------------------------------------------------------*/
......@@ -106,19 +84,13 @@ namespace datwrite {
/*----------------------------------------------------------------------*/
void odatstream::setlast()
{
Mlast=true;
}
/*----------------------------------------------------------------------*/
void odatstream::newtrace()
void odatstream::flushfileheader()
{
Mtracefreeset=false;
Mwid2set=false;
Minfoset=false;
Msrceset=false;
if (!Mheaderflushed)
{
writefileheader();
}
Mheaderflushed=true;
}
/*----------------------------------------------------------------------*/
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: datwrite.h,v 1.5 2010-02-17 22:13:29 tforb Exp $
* $Id: datwrite.h,v 1.6 2010-02-18 12:16:48 tforb Exp $
* \author Thomas Forbriger
* \date 11/04/2006
*
......@@ -40,7 +40,7 @@
#define DATWRITE_DATWRITE_H_VERSION \
"TF_DATWRITE_H V1.0 "
#define DATWRITE_DATWRITE_H_CVSID \
"$Id: datwrite.h,v 1.5 2010-02-17 22:13:29 tforb Exp $"
"$Id: datwrite.h,v 1.6 2010-02-18 12:16:48 tforb Exp $"
namespace datwrite {
......@@ -59,59 +59,61 @@ namespace datwrite {
* Then we have, however, to define a separate mechanism to flush the file
* header.
* Let's think about that.
*
* \note
* Design considerations:
* For most data types it would be convenient to flush data traces to file
* upon a call to odtstream::writeseries().
*/
class odatstream {
public:
virtual ~odatstream() { }
virtual Tdseries dseries() { DATWRITE_illegal; }
virtual Tfseries fseries() { DATWRITE_illegal; }
virtual Tiseries iseries() { DATWRITE_illegal; }
void setfree(const sff::FREE& free);
void setwid2(const sff::WID2& wid2);
void setsrce(const sff::SRCE& srce);
void setinfo(const sff::INFO& info);
virtual void writeseries(const Tdseries& series) { DATWRITE_illegal; }
virtual void writeseries(const Tdseries& series) { DATWRITE_illegal; }
virtual void writeseries(const Tdseries& series) { DATWRITE_illegal; }
void flushfileheader();
//! print some info about data conversion.
static void help(std::ostream& os=std::cout,
char* name="idatsream");
protected:
idatstream(std::ostream& os);
odatstream(std::ostream& os);
std::ostream& Mos;
void setfilefree(const sff::FREE& free);
void settracefree(const sff::FREE& free);
void setwid2(const sff::WID2& wid2);
void setsrce(const sff::SRCE& srce);
void setinfo(const sff::INFO& info);
void setlast();
void newtrace();
virtual void writefileheader();
private:
sff::WID2 Mwid2;
sff::SRCE Msrce;
sff::INFO Minfo;
sff::FREE Mtracefree;
sff::FREE Mfilefree;
bool Mwid2set, Msrceset, Minfoset, Mtracefreeset, Mfilefreeset;
bool Mlast;
bool Mprovidesd, Mprovidesf, Mprovidesi;
}; // class idatstream
sff::FREE Mfree;
bool Mwid2set, Msrceset, Minfoset, Mfreeset;
bool Mheaderflushed;
}; // class odatstream
/*----------------------------------------------------------------------*/
inline idatstream& operator>>(idatstream& is, sff::WID2& wid2)
{ wid2=is.wid2(); return(is); }
inline odatstream& operator<<(odatstream& os, sff::WID2& wid2)
{ os.setwid2(wid2); return(os); }
inline idatstream& operator>>(idatstream& is, sff::SRCE& srce)
{ srce=is.srce(); return(is); }
inline odatstream& operator<<(odatstream& os, sff::SRCE& srce)
{ os.setsrce(srce); return(os); }
inline idatstream& operator>>(idatstream& is, sff::INFO& info)
{ info=is.info(); return(is); }
inline odatstream& operator<<(odatstream& os, sff::INFO& info)
{ os.setinfo(info); return(os); }
inline idatstream& operator>>(idatstream& is, sff::FREE& free)
{ free=is.free(); return(is); }
inline odatstream& operator<<(odatstream& os, sff::FREE& free)
{ os.setfree(free); return(os); }
inline idatstream& operator>>(idatstream& is, Tdseries& series)
{ series=is.dseries(); return(is); }
inline odatstream& operator<<(odatstream& os, Tdseries& series)
{ os.writeseries(series); return(os); }
inline idatstream& operator>>(idatstream& is, Tfseries& series)
{ series=is.fseries(); return(is); }
inline odatstream& operator<<(odatstream& os, Tfseries& series)
{ os.writeseries(series); return(os); }
inline idatstream& operator>>(idatstream& is, Tiseries& series)
{ series=is.iseries(); return(is); }
inline odatstream& operator<<(odatstream& os, Tiseries& series)
{ os.writeseries(series); return(os); }
} // namespace datwrite
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: writeany.cc,v 1.2 2010-02-17 22:00:26 tforb Exp $
* $Id: writeany.cc,v 1.3 2010-02-18 12:16:48 tforb Exp $
* \author Thomas Forbriger
* \date 17/02/2010
*
......@@ -36,12 +36,78 @@
#define DATWRITE_WRITEANY_CC_VERSION \
"TF_WRITEANY_CC V1.0 "
#define DATWRITE_WRITEANY_CC_CVSID \
"$Id: writeany.cc,v 1.2 2010-02-17 22:00:26 tforb Exp $"
"$Id: writeany.cc,v 1.3 2010-02-18 12:16:48 tforb Exp $"
#include <datwritexx/writeany.h>
namespace datwrite {
oanystream::oanystream(std::ostream& os, const Eformat& format,
const bool& debug):
Mformat(format)
{
if (Mformat==Fsff) { Mos=new osffstream(os); }
else if (Mformat==Fgse) { Mos=new ogsestream(os); }
else
{ DATREAD_abort("ERROR (ianystream): unknown format!"); }
}
/*----------------------------------------------------------------------*/
oanystream::~oanystream()
{
delete Mos;
}
/*======================================================================*/
// functions
Eformat anyID(const std::string& id)
{
Eformat retval;
if (id=="sff")
{ retval=Fsff; }
else if (id=="gse")
{ retval=Fgse; }
else { DATREAD_abort("unknown data type identifier!"); }
return(retval);
}
// Eformat anyID(const std::string& identifier)
std::string anyID(const Eformat& id)
{
std::string retval="NSP";
switch(id) {
case Fsff: retval="sff"; break;
case Fgse: retval="gse"; break;
default: DATREAD_abort("unknown data type ID#!");
}
return(retval);
}
// std::string anyID(const Eformat& id)
/*----------------------------------------------------------------------*/
void supported_data_types(std::ostream& os)
{
os << "data formats supported by oanystream:" << std::endl;
os << " sff: Stuttgart File Format" << std::endl;
os << " gse: raw GSE format" << std::endl;
os << DATREAD_READANY_CC_CVSID << std::endl;
}
/*----------------------------------------------------------------------*/
void online_help(std::ostream& os)
{
os << std::endl
<< "Online help obtained from data extraction facilities:"
<< std::endl;
os << "SFF data: "; osffstream::help(os);
os << std::endl;
os << "GSE data: "; ogsestream::help(os);
}
} // namespace datwrite
/* ----- END OF writeany.cc ----- */
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: writeany.h,v 1.2 2010-02-17 22:00:27 tforb Exp $
* $Id: writeany.h,v 1.3 2010-02-18 12:16:48 tforb Exp $
* \author Thomas Forbriger
* \date 17/02/2010
*
......@@ -40,10 +40,58 @@
#define DATWRITE_WRITEANY_H_VERSION \
"DATWRITE_WRITEANY_H V1.0 "
#define DATWRITE_WRITEANY_H_CVSID \
"$Id: writeany.h,v 1.2 2010-02-17 22:00:27 tforb Exp $"
"$Id: writeany.h,v 1.3 2010-02-18 12:16:48 tforb Exp $"
namespace datwrite {
enum Eformat {
Fsff, //<! SFF data
Fgse, //<! raw GSE data
Fascii //<! formatted ASCII data (TF format)
Fbin //<! pure binary data (TF format)
}; // enum Eformat
#define ANYDELEGATE( function ) function() const { return(Mos->function()); }
/*! Class to write any type of data file
*
* Notice: This does not work by inheritance. To select a specific
* type of output stream, we have to keep a reference and to delegate
* any function calls. But this is only necessary for functions that have to
* be called as a member function directly. Functions for which an output
* operator is defined, can by called by the stream output syntax.
* A delegating output operator will be defined below.
*/
class oanystream {
public:
oanystream(std::ostream&, const Eformat& format,
const bool& debug=false);
~oanystream();
datwrite::odatstream& odatstream() { return(*Mos); }
void ANYDELEGATE( flushfileheader )
private:
oanystream(const oanystream&);
oanystream& operator=(const oanystream&);
datwrite::odatstream* Mos;
datwrite::Eformat Mformat;
}; // class ianystream
#undef ANYDELEGATE
// convert identifier from and to string representation
Eformat anyID(const std::string& identifier);
std::string anyID(const Eformat& id);
// print out information about supported data types
void supported_data_types(std::ostream& os=std::cout);
// print out information about data conversion
void online_help(std::ostream& os=std::cout);
template<class C>
oanystream& operator>>(oanystream& os, C& c)
{ os.odatstream() >> c; return(os); }
} // namespace datwrite
#endif // DATWRITE_WRITEANY_H_VERSION (includeguard)
......
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