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

huu - a lot of new code

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.
but doesn't compile yet :-(


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 771
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 07bc65a4
# this is <Makefile>
# ----------------------------------------------------------------------------
# $Id: Makefile,v 1.2 2002-03-25 22:04:06 forbrig Exp $
# $Id: Makefile,v 1.3 2002-03-29 23:35:48 forbrig Exp $
#
# Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
#
......@@ -47,8 +47,9 @@ clean: ;
# library part
# ------------
LIBSRC=gsexx.cc
INCSRC=gsexx.h
LIBSRC=gsexx.cc gsexx_TCHK2.cc gsexx_TWID2.cc gsexx_TSTA2.cc gsexx_TDAT2.cc \
gsexx_cm6.cc
INCSRC=gsexx.h gsexx_diff.h gsexx_TDAT2.h
-include $(patsubst %.cc,%.d,$(LIBSRC))
......@@ -57,7 +58,7 @@ libgsexx.a: $(patsubst %.cc,%.o,$(LIBSRC))
ranlib $@
newlib $@
install-include: ; newinclude $(INCSRC)
install-include: ; newinclude gsexx.h
#======================================================================
# documentation part
......@@ -66,7 +67,7 @@ install-include: ; newinclude $(INCSRC)
doxyclean: ;/bin/rm -rfv doc docbrief
DOXYSRC=README gsexx.h gsexx.cc gsexx_tests.cc
DOXYSRC=README $(LIBSRC) $(INCSRC) gsexx_tests.cc
doc/%: doxyfull.cfg $(DOXYSRC); doxygen $<
docbrief/%: doxybrief.cfg $(DOXYSRC); doxygen $<
......@@ -86,7 +87,8 @@ doxyview: doxyfullview doxybrief
# test code
# ---------
gsexx_tests: gsexx_tests.cc; $(CXX) -o $@ $< -I$(LOCINCLUDEDIR)
gsexx_tests: gsexx_tests.cc
$(CXX) -o $@ $< -I$(LOCINCLUDEDIR) -lgsexx -L$(LOCLIBDIR)
tests: gsexx_tests; $<
# ----- END OF Makefile -----
......@@ -3,7 +3,7 @@
----------------------------------------------------------------------------
$Id: README,v 1.1 2002-03-17 21:26:27 forbrig Exp $
$Id: README,v 1.2 2002-03-29 23:35:48 forbrig Exp $
\author Thomas Forbriger
\date 16/03/2002
......@@ -104,6 +104,19 @@ Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
(excluding carriage return). This is essential together with the SFF library
the needs this information to include it in the DAST line. Writer classes
may be attached to a string stream to delay writing to the file.
\todo
Use a preprocessor macro to select the use of libtime. TWID2 holds the
fields in generic types. But in case we provide some conversion functions to
retrieve a libtime class from a WID2 line data class.
\todo
Provide a check for the DAT2 specifier in the constructor for TDAT2read.
\todo
Provide a writing of the DAT2 specifier in the constructor for TDAT2write.
\todo
Provide a check function to look for the next identifier in the file.
*/
/* ----- END OF README ----- */
......@@ -48,8 +48,9 @@ WARN_LOGFILE =
#---------------------------------------------------------------------------
INPUT = ./
FILE_PATTERNS = README \
*.h \
*.cc
gsexx.h \
gsexx_T*cc \
gsexxcc
RECURSIVE = NO
EXCLUDE =
EXCLUDE_PATTERNS =
......
......@@ -9,8 +9,8 @@ OUTPUT_LANGUAGE = English
EXTRACT_ALL = YES
EXTRACT_PRIVATE = YES
EXTRACT_STATIC = YES
HIDE_UNDOC_MEMBERS = YES
HIDE_UNDOC_CLASSES = YES
HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ALWAYS_DETAILED_SEC = YES
......@@ -31,7 +31,7 @@ INLINE_INFO = YES
SORT_MEMBER_DOCS = YES
DISTRIBUTE_GROUP_DOC = YES
TAB_SIZE = 8
ENABLED_SECTIONS =
ENABLED_SECTIONS = internal
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
ALIASES =
......@@ -61,7 +61,7 @@ FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = NO
ALPHABETICAL_INDEX = YES
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
#---------------------------------------------------------------------------
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: gsexx.cc,v 1.3 2002-03-25 22:27:46 forbrig Exp $
* $Id: gsexx.cc,v 1.4 2002-03-29 23:35:48 forbrig Exp $
* \author Thomas Forbriger
* \date 16/03/2002
*
......@@ -13,6 +13,7 @@
*
* REVISIONS and CHANGES
* - 16/03/2002 V1.0 Thomas Forbriger
* - 29/03/2002 V1.1 moved class specific stuff to other files
*
* ============================================================================
*/
......@@ -20,177 +21,52 @@
#define TF_GSEXX_CC_VERSION \
"TF_GSEXX_CC V1.0 "
#define TF_GSEXX_CC_CVSID \
"$Id: gsexx.cc,v 1.3 2002-03-25 22:27:46 forbrig Exp $"
"$Id: gsexx.cc,v 1.4 2002-03-29 23:35:48 forbrig Exp $"
#include<cmath>
#include <gsexx.h>
namespace GSE2 {
namespace waveform {
/*======================================================================*/
/*! \brief Stuff to apply and remove first, second and higher differences.
*
* These operators are only used within the reading and writing classes. Thus
* we declare them here - hidden from the public.
*
* The Tdiff_operator template provides a means to apply or remove differences
* of any order from an integer data stream. To use this feature: Create an
* object of the desired operator class. Feed the input datastream sample by
* sample into the class' operator function. It returns the samples with
* differences applied or removed.
*
* \sa apply1stdiffT, apply2nddiffT, remove1stdiffT, remove2nddiffT
*/
namespace differences {
/*! \brief Elementary operator to calculate differences.
*
* \note
* This is the place, where overflow-checkking could be done.
*/
class Tapply_diff {
public:
Tapply_diff(): Mxold(0) { }
int operator()(const intT& x)
{
intT xold=Mxold;
Mxold=x;
return(x-xold);
}
private:
intT Mxold;
}; // Tapply_diff
/*! \brief Elementary operator to calculate the sum, which removes differences.
*
* \note
* This is the place, where overflow-checkking could be done.
*/
class Tremove_diff {
public:
Tremove_diff(): Mxold(0) { }
intT operator()(const intT& x)
{ return(Mxold=Mxold+x); }
private:
intT Mxold;
}; // Tremove_diff
/*! \brief Template to apply or remove differences of any order.
/*! \namespace GSE2
*
* This template expands recursively and thus provides an operator of the
* requested order.
* This namespace holds stuff related to the GSE2 format specification.
* The module includes material for the GSE2.0 subformat and the GSE2.1
* subformat. It is subdevided into modules for waveforms (provided in
* GSE2::waveform) and others, which are not yet defined.
* \sa GSE2::waveform
*
* Template parameters are:
* \param n order of differences
* \param OP operator, which could be Tapply_diff or Tremove_diff
* \if internal
* \par Internal modules
* The submodules GSE2::tests contains functions performing test cases on the
* GSE2 module elements.
* \sa GSE2::tests
* \endif
*/
template<int n, class OP>
class Tdiff_operator {
public:
intT operator()(const intT& val) { return(Mop(Mdiff(val))); }
private:
OP Mop;
Tdiff_operator<n-1, OP> Mdiff;
}; // Tdiff_operator<n, OP>
namespace GSE2 {
/*! \brief Template specialization for order zero.
/*! \namespace GSE2::waveform
*
* Just copy the value. Never use this directly (it just copies numbers). This
* specialization is necessary to stop the template expansion recursion.
* This submodule contains classes and functions for reading and writing GSE2
* waveform data.
*
* Tamplate parameter:
* \param OP operator, which could be Tapply_diff or Tremove_diff
*/
template<class OP>
class Tdiff_operator<0, OP> {
public:
intT operator()(const intT& val) { return(val); }
}; // Tdiff_operator<0, OP>
} // namespace differences
//! Operator to apply first differences
typedef differences::Tdiff_operator<1, differences::Tapply_diff>
apply1stdiffT;
//! Operator to apply second differences
typedef differences::Tdiff_operator<2, differences::Tapply_diff>
apply2nddiffT;
//! Operator to remove first differences
typedef differences::Tdiff_operator<1, differences::Tremove_diff>
remove1stdiffT;
//! Operator to remove second differences
typedef differences::Tdiff_operator<2, differences::Tremove_diff>
remove2nddiffT;
/*======================================================================*/
/*! \class TWID2
*
* \note
* The auxid field should only be used if the channel id non-unique.
*/
/*======================================================================*/
/*! \class TCHK2
* \if internal
* \par Internal modules
* You will find additional submodules. They are
*
* \arg GSE2::waveform::differences contains template metaprograms that apply
* first or second (or higher) differences to a data stream (or remove
* them).
* \arg GSE2::waveform::cm6 containes function for encoding and decoding the
* data in the CM6 subformat.
*
* This class allows the cumulative calculation of checksums. The code is take
* from the Appendix A.1 from the Conference Room Paper/243 of the Group of
* Scientific Experts.
*/
/*!
* This function adds the sample value to the checksum.
* \sa GSE2::waveform::differences
* \sa GSE2::waveform::cm6
* \endif
*
* \param value sample value to add
* \sa GSE2::waveform::TWID2
* \sa GSE2::waveform::TSTA2
* \sa GSE2::waveform::TDAT2
* \sa GSE2::waveform::TCHK2
*/
void TCHK2::add(const intT& value)
{
const intT modulo=100000000; // a one and eight zeros
intT sample_value=value;
// check for sample value overflow
if (abs(sample_value) >= modulo)
{
sample_value = sample_value - (sample_value/modulo)*modulo;
}
// add the sample value to the checksum
Msum += sample_value;
// check for checksum overflow
if (abs(Msum) >= modulo)
{
Msum = Msum - (Msum/modulo)*modulo;
}
}
/*----------------------------------------------------------------------*/
/*! \relates TCHK2
* Write a checksum CHK2-line to a GSE data file.
*/
std::ostream& operator<<(std::ostream& os, const TCHK2& chk2)
{
os.width(4); os << "CHK2 ";
os.width(8); os << chk2.value();
os << endl;
}
/*! \relates TCHK2
* Read a checksum CHK2-line from a GSE data file.
*/
std::istream& operator>>(std::istream& os, TCHK2& chk2)
{
cerr << "std::istream& operator>>(std::istream& os, TCHK2& chk2)" <<
<< endl
<< "not yet defined!" << endl;
abort();
}
namespace waveform {
} // namespace waveform
} // namespace GSE2
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: gsexx.h,v 1.3 2002-03-25 22:27:46 forbrig Exp $
* $Id: gsexx.h,v 1.4 2002-03-29 23:35:48 forbrig Exp $
* \author Thomas Forbriger
* \date 16/03/2002
*
......@@ -23,7 +23,7 @@
#define TF_GSEXX_H_VERSION \
"TF_GSEXX_H V1.0 "
#define TF_GSEXX_H_CVSID \
"$Id: gsexx.h,v 1.3 2002-03-25 22:27:46 forbrig Exp $"
"$Id: gsexx.h,v 1.4 2002-03-29 23:35:48 forbrig Exp $"
// #include <libtime++.h>
#include<string>
......@@ -81,6 +81,172 @@ std::ostream& operator<<(std::ostream&, const TCHK2& chk2);
//! Input TCHK2 object from stream.
std::istream& operator>>(std::istream&, TCHK2& chk2);
/*======================================================================*/
/*
* modules to apply and remove differnces must be declared here
* ------------------------------------------------------------
*/
// declare internal differencing stuff in advance
// we need it below for the compression subformat classes
/*!
* \todo
* sorry must provide full code, since we want to use this class as a member
* type below :-(
*/
namespace differences {
class Tapply_diff;
class Tremove_diff;
template<int n, class OP>
class Tdiff_operator;
}
//! Operator to apply first differences
typedef differences::Tdiff_operator<1, differences::Tapply_diff>
apply1stdiffT;
//! Operator to apply second differences
typedef differences::Tdiff_operator<2, differences::Tapply_diff>
apply2nddiffT;
//! Operator to remove first differences
typedef differences::Tdiff_operator<1, differences::Tremove_diff>
remove1stdiffT;
//! Operator to remove second differences
typedef differences::Tdiff_operator<2, differences::Tremove_diff>
remove2nddiffT;
/*======================================================================*/
/*
* All stuff for DAT2 reading and writing
* --------------------------------------
*/
//! Handle checksum and sample count
class TDAT2sum {
public:
//! return the checksum
const TCHK2& checksum() const { return(Mchecksum); }
//! return the number of samples read
intT nread() const { return(Mnsamp); }
//! return total number of samples to read
intT msamp() const { return(Mmsamp); }
//! return true if not all samples are processed
bool hot() const { return((Mnsamp<Mmsamp)); }
protected:
//! only derived class should create an instance
TDAT2sum(const intT& msamp): Mnsamp(0), Mmsamp(msamp) { }
//! count a sample
void add(const intT& value);
private:
//! The checksum is handled by the base class.
TCHK2 Mchecksum;
//! number of samples read
intT Mnsamp;
//! total number of samples to read
intT Mmsamp;
}; // TDAT2sum
// inline add function
inline void TDAT2sum::add(const intT& value)
{
Mchecksum.add(value);
++Mnsamp;
}
/*----------------------------------------------------------------------*/
//! Abstract base class for reading %GSE2 %waveform data.
class TDAT2read: public TDAT2sum
{
public:
//! get another value from the stream
intT get();
protected:
//! constructor to be called from implementation class
TDAT2read(istream& is, const intT& msamp):
TDAT2sum(msamp), Mis(is) { }
private:
//! get from stream: user must define
virtual intT get_from_stream() = 0;
protected:
//! reference to stream we read from
istream& Mis;
}; // TDAT2read
// inline get wrapper function
inline intT TDAT2read::get()
{
intT retval=get_from_stream();
add(retval);
return(retval);
}
/*----------------------------------------------------------------------*/
//! Abstract base class for writing %GSE2 %waveform data.
class TDAT2write: public TDAT2sum
{
public:
//! write another value to the stream
void put(const intT& value);
protected:
//! constructor to be called from implementation class
TDAT2write(ostream& os, const intT& msamp, const intT& linelength):
TDAT2sum(msamp), Mos(os), Mlinelength(linelength), Mcpos(0) { }
private:
//! put to stream: user must define
virtual void put_to_stream(const intT& value) = 0;
protected:
//! reference to stream we write to
ostream& Mos;
//! linelength in output file
intT Mlinelength;
//! character position in line
intT Mcpos;
}; // TDAT2write
// inline put wrapper function
inline void TDAT2write::put(const intT& value)
{
add(value);
put_to_stream(value);
}
/*----------------------------------------------------------------------*/
//! Derived class for reading %CM6 subformat data.
class TDAT2readCM6: public TDAT2read
{
public:
//! constructor of implementation class
TDAT2readCM6(istream& is, const intT& msamp):
TDAT2read(is, msamp) { }
private:
//! get from stream: user must define
virtual intT get_from_stream() = 0;
private:
//! only compression formats apply differences.
remove2nddiffT Mremovediff;
}; // TDAT2readCM6
/*----------------------------------------------------------------------*/
//! Derived class for writing %CM6 subformat data.
class TDAT2writeCM6:public TDAT2write
{
public:
//! constructor of implementation class
TDAT2writeCM6(ostream& os, const intT& msamp, const intT& linelength=80):
TDAT2write(os, msamp, linelength) { }
private:
//! put to stream: user must define
virtual void put_to_stream(const intT& value);
private:
//! only compression formats apply differences.
apply2nddiffT Mapplydiff;
}; // TDAT2writeCM6
/*======================================================================*/
} // namespace waveform
} // namespace GSE2
......
/*! \file gsexx_TCHK2.cc
* \brief definition of TCHK2 functions (implementation)
*
* ----------------------------------------------------------------------------
*
* $Id: gsexx_TCHK2.cc,v 1.1 2002-03-29 23:35:48 forbrig Exp $
* \author Thomas Forbriger
* \date 29/03/2002
*
* definition of TCHK2 functions (implementation)
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
* REVISIONS and CHANGES
* - 29/03/2002 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define TF_GSEXX_TCHK2_CC_VERSION \
"TF_GSEXX_TCHK2_CC V1.0 "
#define TF_GSEXX_TCHK2_CC_CVSID \
"$Id: gsexx_TCHK2.cc,v 1.1 2002-03-29 23:35:48 forbrig Exp $"
#include<cmath>
#include <gsexx.h>
namespace GSE2 {
namespace waveform {
/*! \class TCHK2
*
* This class allows the cumulative calculation of checksums. The code is take
* from the Appendix A.1 from the Conference Room Paper/243 of the Group of
* Scientific Experts.
*/
/*!
* This function adds the sample value to the checksum.
*
* \param value sample value to add
*/
void TCHK2::add(const intT& value)
{
const intT modulo=100000000; // a one and eight zeros
intT sample_value=value;
// check for sample value overflow
if (abs(sample_value) >= modulo)
{
sample_value = sample_value - (sample_value/modulo)*modulo;
}
// add the sample value to the checksum
Msum += sample_value;
// check for checksum overflow
if (abs(Msum) >= modulo)
{
Msum = Msum - (Msum/modulo)*modulo;
}
}
/*----------------------------------------------------------------------*/
/*! \relates TCHK2
* Write a checksum CHK2-line to a GSE data file.
*/
std::ostream& operator<<(std::ostream& os, const TCHK2& chk2)
{
os.width(4); os << "CHK2 ";
os.width(8); os << chk2.value();
os << endl;
return(os);
}
/*----------------------------------------------------------------------*/
/*! \relates TCHK2
* Read a checksum CHK2-line from a GSE data file.
*/
std::istream& operator>>(std::istream& is, TCHK2& chk2)
{
cerr << "std::istream& operator>>(std::istream& os, TCHK2& chk2)"
<< endl
<< "not yet defined!" << endl;
abort();
return(is);
}
} // namespace waveform
} // namespace GSE2
/* ----- END OF gsexx_TCHK2.cc ----- */
/*! \file gsexx_TDAT2.cc
* \brief definition of TDAT2 functions (implementation)