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

started libgsexx project (C++ functions for reading and writing GSE data)

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: 751
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent a1fdaf6d
This is a legacy version of the repository. It may be incomplete as well as
inconsistent. See README.history for details. For the old stock of the
repository copyright and licence conditions apply as specified for versions
commited after 2015-03-01. Use recent versions as a base for new development.
The legacy version is only stored to keep a record of history.
# this is <Makefile>
# ----------------------------------------------------------------------------
# $Id: Makefile,v 1.1 2002-03-17 21:26:27 forbrig Exp $
#
# Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
#
# GSE++ library to read and write GSE waveforms
#
# REVISIONS and CHANGES
# 16/03/2002 V1.0 Thomas Forbriger
#
# ============================================================================
# general part
# ------------
#
FLAGS=
CXXFLAGS=-fhonor-std -Wall $(FLAGS)
CXXFLAGS=-Wall $(FLAGS)
LDFLAGS=-L$(LOCLIBDIR)
CPPFLAGS=-I$(LOCINCLUDEDIR) $(FLAGS)
all: libgsexx.a doxybrief doxyfull
flist: Makefile README $(wildcard *.h *.cc *.cfg)
echo $^ | tr ' ' '\n' | sort > $@
.PHONY: edit
edit: flist; vim $<
.PHONY: clean
clean: ;
-find . -name \*.bak | xargs --no-run-if-empty /bin/rm -v
-/bin/rm -vf flist *.d *.o
#======================================================================
# pattern rules
# -------------
%.d: %.cc
$(SHELL) -ec '$(CXX) -M $(CPPFLAGS) $< \
| sed '\''s,\($(notdir $*)\)\.o[ :]*,$(dir $@)\1.o $@ : ,g'\'' \
> $@; \
[ -s $@ ] || rm -f $@'
#======================================================================
# library part
# ------------
LIBSRC=gsexx.cc
INCSRC=gsexx.h
-include $(patsubst %.cc,%.d,$(LIBSRC))
libgsexx.a: $(patsubst %.cc,%.o,$(LIBSRC))
ar rcv $@ $^
ranlib $@
newlib $@
install-include: ; newinclude $(INCSRC)
#======================================================================
# documentation part
# ------------------
.PHONY: doxyclean doxyview doxybriefview doxyfullconf doxybriefconf
doxyclean: ;/bin/rm -rfv doc docbrief
DOXYSRC=README gsexx.h gsexx.cc
doc/%: doxyfull.cfg $(DOXYSRC); doxygen $<
docbrief/%: doxybrief.cfg $(DOXYSRC); doxygen $<
doxybriefconf doxyfullconf: doxy%conf:
doxywizard $(patsubst doxy%conf,doxy%.cfg,$@)
doxybrief: docbrief/html/index.html
doxyfull: doc/html/index.html
doxydoc: doxybrief doxyfull
doxyfullview: doxyfull; netscape doc/html/index.html &
doxybriefview: doxybrief; netscape docbrief/html/index.html &
doxyview: doxyfullview doxybrief
# ----- END OF Makefile -----
/*! \file README
\brief GSE++ library (documentation)
----------------------------------------------------------------------------
$Id: README,v 1.1 2002-03-17 21:26:27 forbrig Exp $
\author Thomas Forbriger
\date 16/03/2002
GSE++ library (implementation)
Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
REVISIONS and CHANGES
- 16/03/2002 V1.0 Thomas Forbriger
============================================================================
*/
/*! \mainpage
\author Thomas Forbriger
\date 16/03/2002
GSE++ library: reading and writing GSE waveforms
Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
\section history Revisions and changes
- 16/03/2002 V1.0 Thomas Forbriger
\section goal Goal of the library
This library supports reading and writing of waveforms as defined by the
GSE2.1 standard (Provisional GSE2.1 Formats and Protocols, May 1997).
The library defines a modul GSE21::waveform. This modul containes classes
(TWID2, TSTA2) that hold GSE21 format elements. Further it contains
functions to read and write waveform data in subformats CM6.
\section design Design Decisions
\subsection services Services and header files
The central aim of the library is to provide reading and writing of GSE2
data subformats (mainly CM6).
Since the main goal is reading and writing, the iostream headre will always
be included together with the libgsexx.h header.
For ease of implementation the libgse.h always includes the string module
and the libtime module. Both are integral parts of the TWID2 class. They may
not easily be ommited.
\subsection GSEandSFF GSE2.1, GSE2.0 and SFF
With GSE2.0 the straight concept was to write a full waveform at once,
consisting of a WID2 line, a DAT2 identifier, the actual waveform data in
any sub-format encoding and a CHK2 line. This was totally compatible to the
SFF (Stuttgart File Format). With GSE2.1, however, a new STA2 line was
introduced. This GSE2.1 this line is mandatory. But it doesn't appear in the
SFF specification and is thus not allowed with in SFF data.
There are many reasons for reading and writing the full waveform set at
once. The main reason is, that the WID2 line holds crucial information about
the actual waveform data (i.e. the sub-format specification and the number
of samples).
\subsection classes Classes
TDAT2reader and TDAT2writer are the interface classes to the core of this
module. The are pure abstract classes. Implementations of this conecpt are
TCM6reader, TCM6writer, TCM8reader, TCM8writer, TINTreader, and TINTwriter,
of which only the CM6 types will be implemented in a first version. The
TWID2 class provides member functions to return an appropriate
implementation for reading or writing the GSE waveform sub-format selected
in the WID2 line.
Two classes T2nddiffrem and T2nddiffappl are helper classes the remove or
apply second differences from/to the integer data stream. They are used with
in the reader and writer classes.
The classes TWID2 and TSTA2 simply hold the data from the corresponding GSE2
format lines. Further there are input/output operators that provide reading
and writing from/to streams.
A class TCHK2 deals with the checksum. It may be initialized from an array.
In this case the checksum is calculated from the values in the array. Or it
may be initialized from an input stream, thus reading the CHK2 line. further
there is a stream input/output provided to read/write a CHK2 line from/to a
stream.
\par The reader classes
The reader classes take a reference to an input stream on initialization.
They are further attached to this stream. They provide a read function that
allows bytewise reading from the input stream. The reader classes provide a
function that returns the number of characters read so far from the input
stream.
\par The writer classes
The writer classes take a reference to an output stream on initialization.
Further they are attached to this stream. They provide a write function that
allows bytewise feeding to the output stream. The writer classes provide a
function the returns the number of characters written to the stream
(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.
*/
/* ----- END OF README ----- */
# Doxygen configuration generated by Doxywizard version 0.1
#---------------------------------------------------------------------------
# General configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = "GSE++ library: reading and writing GSE waveforms"
PROJECT_NUMBER =
OUTPUT_DIRECTORY = docbrief
OUTPUT_LANGUAGE = English
EXTRACT_ALL = NO
EXTRACT_PRIVATE = NO
EXTRACT_STATIC = NO
HIDE_UNDOC_MEMBERS = YES
HIDE_UNDOC_CLASSES = YES
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ALWAYS_DETAILED_SEC = NO
FULL_PATH_NAMES = NO
STRIP_FROM_PATH =
INTERNAL_DOCS = NO
CLASS_DIAGRAMS = YES
SOURCE_BROWSER = NO
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
CASE_SENSE_NAMES = YES
HIDE_SCOPE_NAMES = NO
VERBATIM_HEADERS = YES
SHOW_INCLUDE_FILES = YES
JAVADOC_AUTOBRIEF = YES
INHERIT_DOCS = YES
INLINE_INFO = YES
SORT_MEMBER_DOCS = YES
DISTRIBUTE_GROUP_DOC = YES
TAB_SIZE = 8
ENABLED_SECTIONS =
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
ALIASES =
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = NO
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = ./
FILE_PATTERNS = README \
*.h \
*.cc
RECURSIVE = NO
EXCLUDE =
EXCLUDE_PATTERNS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS =
IMAGE_PATH =
INPUT_FILTER =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = NO
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
DISABLE_INDEX = NO
ENUM_VALUES_PER_LINE = 4
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
GENERATE_LATEX = YES
LATEX_OUTPUT = latex
COMPACT_LATEX = YES
PAPER_TYPE = a4wide
EXTRA_PACKAGES = pslatex
LATEX_HEADER =
PDF_HYPERLINKS = NO
USE_PDFLATEX = NO
LATEX_BATCHMODE = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
GENERATE_RTF = YES
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
GENERATE_MAN = YES
MAN_OUTPUT = man
MAN_EXTENSION = .3
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
GENERATE_XML = NO
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED =
EXPAND_AS_DEFINED =
#---------------------------------------------------------------------------
# Configuration::addtions related to external references
#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE =
ALLEXTERNALS = NO
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
HAVE_DOT = NO
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
GRAPHICAL_HIERARCHY = YES
DOT_PATH =
MAX_DOT_GRAPH_WIDTH = 1024
MAX_DOT_GRAPH_HEIGHT = 1024
GENERATE_LEGEND = YES
#---------------------------------------------------------------------------
# Configuration::addtions related to the search engine
#---------------------------------------------------------------------------
SEARCHENGINE = NO
CGI_NAME = search.cgi
CGI_URL =
DOC_URL =
DOC_ABSPATH =
BIN_ABSPATH = /usr/local/bin/
EXT_DOC_PATHS =
# Doxygen configuration generated by Doxywizard version 0.1
#---------------------------------------------------------------------------
# General configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = "GSE++ library: reading and writing GSE waveforms"
PROJECT_NUMBER =
OUTPUT_DIRECTORY = doc
OUTPUT_LANGUAGE = English
EXTRACT_ALL = YES
EXTRACT_PRIVATE = YES
EXTRACT_STATIC = YES
HIDE_UNDOC_MEMBERS = YES
HIDE_UNDOC_CLASSES = YES
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ALWAYS_DETAILED_SEC = YES
FULL_PATH_NAMES = NO
STRIP_FROM_PATH =
INTERNAL_DOCS = YES
CLASS_DIAGRAMS = YES
SOURCE_BROWSER = YES
INLINE_SOURCES = YES
STRIP_CODE_COMMENTS = YES
CASE_SENSE_NAMES = YES
HIDE_SCOPE_NAMES = NO
VERBATIM_HEADERS = YES
SHOW_INCLUDE_FILES = YES
JAVADOC_AUTOBRIEF = YES
INHERIT_DOCS = YES
INLINE_INFO = YES
SORT_MEMBER_DOCS = YES
DISTRIBUTE_GROUP_DOC = YES
TAB_SIZE = 8
ENABLED_SECTIONS =
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
ALIASES =
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = NO
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = ./
FILE_PATTERNS = README \
*.h \
*.cc
RECURSIVE = NO
EXCLUDE =
EXCLUDE_PATTERNS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS =
IMAGE_PATH =
INPUT_FILTER =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = NO
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
DISABLE_INDEX = NO
ENUM_VALUES_PER_LINE = 4
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
GENERATE_LATEX = YES
LATEX_OUTPUT = latex
COMPACT_LATEX = YES
PAPER_TYPE = a4wide
EXTRA_PACKAGES = pslatex
LATEX_HEADER =
PDF_HYPERLINKS = NO
USE_PDFLATEX = NO
LATEX_BATCHMODE = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
GENERATE_RTF = YES
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
GENERATE_MAN = YES
MAN_OUTPUT = man
MAN_EXTENSION = .3
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
GENERATE_XML = NO
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED =
EXPAND_AS_DEFINED =
#---------------------------------------------------------------------------
# Configuration::addtions related to external references
#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE =
ALLEXTERNALS = NO
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
HAVE_DOT = NO
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
GRAPHICAL_HIERARCHY = YES
DOT_PATH =
MAX_DOT_GRAPH_WIDTH = 1024
MAX_DOT_GRAPH_HEIGHT = 1024
GENERATE_LEGEND = YES
#---------------------------------------------------------------------------
# Configuration::addtions related to the search engine
#---------------------------------------------------------------------------
SEARCHENGINE = NO
CGI_NAME = search.cgi
CGI_URL =
DOC_URL =
DOC_ABSPATH =
BIN_ABSPATH = /usr/local/bin/
EXT_DOC_PATHS =
/*! \file gsexx.cc
* \brief GSE++ library: read and write GSE waveform data (implementation).
*
* ----------------------------------------------------------------------------
*
* $Id: gsexx.cc,v 1.1 2002-03-17 21:26:27 forbrig Exp $
* \author Thomas Forbriger
* \date 16/03/2002
*
* GSE++ library: read and write GSE waveform data (implementation)
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
* REVISIONS and CHANGES
* - 16/03/2002 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define TF_GSEXX_CC_VERSION \
"TF_GSEXX_CC V1.0 "
#define TF_GSEXX_CC_CVSID \
"$Id: gsexx.cc,v 1.1 2002-03-17 21:26:27 forbrig Exp $"
#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 int& x)
{
int xold=Mxold;
Mxold=x;
return(x-xold);
}
private:
int 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) { }
int operator()(const int& x)
{ return(Mxold=Mxold+x); }
private:
int Mxold;
}; // Tremove_diff
/*! \brief Template to apply or remove differences of any order.
*
* This template expands recursively and thus provides an operator of the
* requested order.
*
* Template parameters are:
* \param n order of differences
* \param OP operator, which could be Tapply_diff or Tremove_diff
*/
template<int n, class OP>
class Tdiff_operator {
public:
int operator()(const int& val) { return(Mop(Mdiff(val))); }
private:
OP Mop;
Tdiff_operator<n-1, OP> Mdiff;
}; // Tdiff_operator<n, OP>
/*! \brief Template specialization for order zero.
*
* Just copy the value. Never use this directly (it just copies numbers). This
* specialization is necessary to stop the template expansion recursion.
*
* Tamplate parameter:
* \param OP operator, which could be Tapply_diff or Tremove_diff
*/
template<class OP>
class Tdiff_operator<0, OP> {
public:
int operator()(const int& val) { return(val); }
}; // Tdiff_operator<0, OP>
} // namespace differences
//! Operator to apply first differences
typedef differences::Tdiff_operator<1, Tapply_diff> apply1stdiffT;
//! Operator to apply second differences
typedef differences::Tdiff_operator<2, Tapply_diff> apply2nddiffT;
//! Operator to remove first differences
typedef differences::Tdiff_operator<1, Tremove_diff> remove1stdiffT;
//! Operator to remove second differences
typedef differences::Tdiff_operator<2, Tremove_diff> remove2nddiffT;
/*======================================================================*/
/*! \class TWID2
*
* \note
* The auxid field should only be used if the channel id non-unique.
*/
} // namespace waveform
} // namespace GSE2
/* ----- END OF gsexx.cc ----- */
/*! \file gsexx.h
* \brief GSE++ library: read and write GSE waveform data (prototypes).
*