Commit 9a3b0f3e authored by Jonas Stienen's avatar Jonas Stienen
Browse files

Adding initial data

parent b6a4e6fb
cmake_minimum_required( VERSION 2.8 )
project( ITABase )
list( APPEND CMAKE_MODULE_PATH "$ENV{VISTA_CMAKE_COMMON}" )
include( VistaCommon )
# dependencies
vista_use_package( VistaCoreLibs REQUIRED FIND_DEPENDENCIES COMPONENTS VistaInterProcComm VistaTools )
vista_use_package( sndfile )
vista_use_package( IPP QUIET )
vista_use_package( PCRE QUIET )
vista_use_package( SimpleIni QUIET )
if( NOT DEFINED ITA_BASE_WITH_FASTMATH_IPP )
set( ITA_BASE_WITH_FASTMATH_IPP OFF CACHE BOOL "Build with IPP implementation of fast math ops" )
endif( NOT DEFINED ITA_BASE_WITH_FASTMATH_IPP )
if( NOT DEFINED ITA_BASE_WITH_FASTMATH_ASSEMBLER )
set( ITA_BASE_WITH_FASTMATH_ASSEMBLER OFF CACHE BOOL "Build with assembler implementation of fast math ops" )
endif( NOT DEFINED ITA_BASE_WITH_FASTMATH_ASSEMBLER )
if( NOT DEFINED ITA_BASE_WITH_SNDFILE )
set( ITA_BASE_WITH_SNDFILE ON CACHE BOOL "Build with libsndfile to read/write audio samples for ITASampleFrame" )
endif( NOT DEFINED ITA_BASE_WITH_SNDFILE )
if( NOT DEFINED ITA_BASE_WITH_OLD_ATOMICS )
set( ITA_BASE_WITH_OLD_ATOMICS OFF CACHE BOOL "Build with legacy atomic code for non-C++11 compatible compilers" )
endif( NOT DEFINED ITA_BASE_WITH_OLD_ATOMICS )
if( NOT DEFINED ITA_BASE_WITH_REGULAR_EXPRESSIONS )
set( ITA_BASE_WITH_REGULAR_EXPRESSIONS OFF CACHE BOOL "Build with legacy regular expressions code for string manipulation" )
endif( NOT DEFINED ITA_BASE_WITH_REGULAR_EXPRESSIONS )
if( NOT DEFINED ITA_BASE_WITH_CONFIG_OLD_IMPL )
set( ITA_BASE_WITH_CONFIG_OLD_IMPL OFF CACHE BOOL "Build with legacy INI file configuration implementation (uses legacy regular expressions)" )
endif( NOT DEFINED ITA_BASE_WITH_CONFIG_OLD_IMPL )
# includes
include_directories( "include" )
# files
set( ITABaseHeader
"include/ITAASCIITable.h"
"include/ITABaseDefinitions.h"
"include/ITABufferedAudioFileWriter.h"
"include/ITAClock.h"
"include/ITAConstants.h"
"include/ITACriticalSection.h"
"include/ITADataLog.h"
"include/ITAEndianness.h"
"include/ITAException.h"
"include/ITAFade.h"
"include/ITAFastMath.h"
"include/ITAFileSystemUtils.h"
"include/ITAHDFTSpectrum.h"
"include/ITAFunctors.h"
"include/ITAHPT.h"
"include/ITAMutex.h"
"include/ITANumericUtils.h"
"include/ITASampleBuffer.h"
"include/ITASampleFrame.h"
"include/ITASampleTypeConversion.h"
"include/ITAStopWatch.h"
"include/ITAStringUtils.h"
"include/ITATimer.h"
"include/ITATimeSeriesAnalyzer.h"
"include/ITATypes.h"
"include/ITAUncopyable.h"
"include/ITAWinPCClock.h"
"include/spline.h"
)
set( ITABaseSources
"src/ITAASCIITable.cpp"
"src/ITABufferedAudioFileWriter.cpp"
"src/ITAClock.cpp"
"src/ITACriticalSection.cpp"
"src/ITACriticalSectionImpl.h"
"src/ITACriticalSectionPosixImpl.h"
"src/ITACriticalSectionWin32Impl.h"
"src/ITAEndianness.cpp"
"src/ITAException.cpp"
"src/ITAFade.cpp"
"src/ITAFileSystemUtils.cpp"
"src/ITAHDFTSpectrum.cpp"
"src/ITAHPT.cpp"
"src/ITAMutex.cpp"
"src/ITANumericUtils.cpp"
"src/ITASampleBuffer.cpp"
"src/ITASampleFrame.cpp"
"src/ITASampleTypeConversion.cpp"
"src/ITAStopWatch.cpp"
"src/ITATimer.cpp"
"src/ITAWinPCClock.cpp"
"src/spline.cpp"
)
if( VSNDFILE_FOUND AND ITA_BASE_WITH_SNDFILE )
set( ITABaseHeader "${ITABaseHeader}"
"include/ITAAudiofileCommon.h"
"include/ITAAudiofileReader.h"
"include/ITAAudiofileWriter.h"
)
set( ITABaseSources "${ITABaseSources}"
"src/ITAAudiofileCommon.cpp"
"src/ITAAudiofileReader.cpp"
"src/ITAAudiofileWriter.cpp"
"src/libsndfileAudiofileReader.cpp"
"src/libsndfileAudiofileWriter.cpp"
)
endif( VSNDFILE_FOUND AND ITA_BASE_WITH_SNDFILE )
if( VIPP_FOUND AND ITA_BASE_WITH_FASTMATH_IPP )
set( ITABaseSources "${ITABaseSources}" "src/ITAFastMathImplIPP.cpp" )
elseif( ITA_BASE_WITH_FASTMATH_ASSEMBLER )
set( ITABaseSources "${ITABaseSources}" "src/ITAFastMathImplAssembler.cpp" ) # not recommended
else( VIPP_FOUND AND ITA_BASE_WITH_FASTMATH_IPP )
set( ITABaseSources "${ITABaseSources}" "src/ITAFastMathImpl.cpp" )
endif( VIPP_FOUND AND ITA_BASE_WITH_FASTMATH_IPP )
if( ITA_BASE_WITH_OLD_ATOMICS )
set( ITABaseHeader "${ITABaseHeader}" "include/ITAAtomicOps.h" "include/ITAAtomicPrimitives.h")
if( WIN32 )
set( ITABaseSources "${ITABaseSources}" "src/ITAAtomicOpsWin32Impl.cpp" )
else( WIN32 )
set( ITABaseSources "${ITABaseSources}" "src/ITAAtomicOpsGCCBuiltinsImpl.cpp" )
endif( WIN32 )
endif( ITA_BASE_WITH_OLD_ATOMICS )
if( VPCRE_FOUND AND ITA_BASE_WITH_REGULAR_EXPRESSIONS )
list( APPEND ITABaseHeader "include/ITAConfigUtils.h" )
list( APPEND ITABaseSources "src/ITAConfigUtils.cpp" "src/ITAStringUtilsPCRE.cpp" )
add_definitions( -DPCRE_STATIC )
else( VPCRE_FOUND AND ITA_BASE_WITH_REGULAR_EXPRESSIONS )
list( APPEND ITABaseSources "src/ITAStringUtils.cpp" )
endif( VPCRE_FOUND AND ITA_BASE_WITH_REGULAR_EXPRESSIONS )
if( VSIMPLEINI_FOUND AND ITA_BASE_WITH_CONFIG_SIMPLE_INI )
if( NOT ITA_BASE_WITH_REGULAR_EXPRESSIONS )
message( FATAL_ERROR "ITABase old config implementation requires regular expressions. Please activate." )
endif( NOT ITA_BASE_WITH_REGULAR_EXPRESSIONS )
list( APPEND ITABaseSources "src/ITAConfigUtilsSimpleIniImpl.cpp" )
endif( VSIMPLEINI_FOUND AND ITA_BASE_WITH_CONFIG_SIMPLE_INI )
if( ITA_BASE_WITH_CONFIG_OLD_IMPL AND NOT ITA_BASE_WITH_CONFIG_SIMPLE_INI )
if( NOT ITA_BASE_WITH_REGULAR_EXPRESSIONS )
message( FATAL_ERROR "ITABase old config implementation requires regular expressions. Please activate." )
endif( NOT ITA_BASE_WITH_REGULAR_EXPRESSIONS )
list( APPEND ITABaseSources "src/ITAConfigUtilsWin32Impl.cpp" )
endif( ITA_BASE_WITH_CONFIG_OLD_IMPL AND NOT ITA_BASE_WITH_CONFIG_SIMPLE_INI )
# compiler
add_definitions( -DITA_BASE_DLL -DITA_BASE_EXPORT )
# linker
add_library( ITABase SHARED ${ITABaseHeader} ${ITABaseSources} )
target_link_libraries( ITABase ${VISTA_USE_PACKAGE_LIBRARIES} )
# configure
vista_configure_lib( ITABase )
vista_install( ITABase )
set( ITABASE_INCLUDE_OUTDIR "${CMAKE_CURRENT_SOURCE_DIR}/include" )
vista_create_cmake_configs( ITABase )
vista_create_default_info_file( ITABase )
set_property( TARGET ITABase PROPERTY FOLDER "ITACoreLibs" )
# tests
set( ITABASE_COMMON_BUILD TRUE )
add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/tests" )
/*
+-----------------------------------------------------------------------+
| |
| ITAToolkit |
| |
| (c) Copyright Institut fr technische Akustik (ITA) |
| RWTH Aachen University of Technology |
| |
+-----------------------------------------------------------------------+
| |
| File: ITAASCIITable.h |
| Purpose: Klasse zur Darstellung von Tabellen als Zeichenketten |
| Authors: Frank Wefers |
| |
+-----------------------------------------------------------------------+
*/
// $Id: ITAASCIITable.h 3881 2014-12-08 15:03:26Z fwefers $
#ifndef INCLUDE_WATCHER_ITA_ASCII_TABLE
#define INCLUDE_WATCHER_ITA_ASCII_TABLE
#include <ITABaseDefinitions.h>
#include <ostream>
#include <string>
#include <vector>
/**
* Diese Hilfsklasse ermglicht die komfortable Ausgabe von Tabellendaten
* als Text (wie z.B. auf der Konsole). Sie kapselt die Tabellendaten und
* stellt eine Rendering-Methode zur Verfgung um die Zeichenketten-
* Darstellung der Tabelle zu erhalten. Spaltenausrichtungen knnen gesetzt
* werden und mehrzeile Spaltenberschriften, sowie Felder werden untersttzt
*/
class ITA_BASE_API ITAASCIITable
{
public:
//! Literal fr Zeilen-/Spaltenenden
static const unsigned int END = 0xFFFFFFFF;
//! Literale fr Ausrichtungen
enum {
LEFT = 0,
CENTER = 1,
RIGHT = 2
};
//! Formate
enum {
TEXT = 0, //!< Ausgabe als Text
DAT, //!< Datenformat
CSV, //!< CSV Format
};
static const int DEFAULT_FORMAT = TEXT;
//! Konstruktor (leere Tabelle)
ITAASCIITable();
//! Konstruktor (Vorgabe der Anzahl Zeilen/Spalten)
ITAASCIITable(unsigned int uiRows, unsigned int uiColumns);
//! Destruktor
virtual ~ITAASCIITable();
//! Anzahl Zeilen zurckgeben
unsigned int rows() const;
//! Anzahl Zeilen zurckgeben
unsigned int columns() const;
//! Eine Zeile einfgen
/**
* \param uiIndex Index der Zeile, nach der die neue Zeile eingefgt wird (optional)
*/
void addRow(unsigned int uiPosition=END);
//! Eine Zeile entfernen
/**
* \param uiIndex Index der Zeile die entfernt werden soll
*/
void removeRow(unsigned int uiRow);
//! Eine Spalte einfgen
/**
* \param uiIndex Index der Spalte, nach der die neue Spalte eingefgt wird (optional)
*/
void addColumn(unsigned int uiPosition=END);
void addColumn(const std::string& sColumnTitle, unsigned int uiPosition=END);
//! Eine Spalte entfernen
/**
* \param uiIndex Index der Zeile die entfernt werden soll
*/
void removeColumn(unsigned int uiColumn);
//! Ausrichtung einer Spalte zurckgeben
unsigned int getColumnJustify(unsigned int uiColumn);
//! Ausrichtung einer Spalte setzen
void setColumnJustify(unsigned int uiColumn, unsigned int uiJustify);
//! Titel einer Spalte zurckgeben
std::string getColumnTitle(unsigned int uiColumn);
//! Titel einer Spalte setzen
void setColumnTitle(unsigned int uiColumn, const std::string& sTitle);
//! Ausrichtung des Titels einer Spalte zurckgeben
unsigned int getColumnTitleJustify(unsigned int uiColumn);
//! Ausrichtung des Titels einer Spalte setzen
void setColumnTitleJustify(unsigned int uiColumn, unsigned int uiJustify);
//! Zelleinhalt zurckgeben
std::string getContent(unsigned int uiRow, unsigned int uiColumn);
//! Zellinhalt setzen
void setContent(unsigned int uiRow, unsigned int uiColumn, const std::string& sContent);
void setContent(unsigned int uiRow, unsigned int uiColumn, const char* pszContent);
void setContent(unsigned int uiRow, unsigned int uiColumn, const bool& bContent);
void setContent(unsigned int uiRow, unsigned int uiColumn, const unsigned int& uiContent);
void setContent(unsigned int uiRow, unsigned int uiColumn, const int& iContent);
void setContent(unsigned int uiRow, unsigned int uiColumn, const float& fContent, int iPrecision=-1);
void setContent(unsigned int uiRow, unsigned int uiColumn, const double& dContent, int iPrecision=-1);
//! Die ASCII-Tabelle rendern
std::ostream& render(std::ostream& os, int iFormat=DEFAULT_FORMAT);
std::ostream& renderText(std::ostream& os);
std::ostream& renderDAT(std::ostream& os);
std::ostream& renderCSV(std::ostream& os);
//! Die ASCII-Tabelle rendern
std::string toString();
protected:
class ITAASCIITableColumn
{
public:
unsigned int uiTitleJustify; // Ausrichtung des Titels
std::string sTitle; // Titel
unsigned int uiJustify; // Ausrichtung der Zellen
std::vector< std::string > vsCells; // Inhalt der Zellen
unsigned int uiMaxWidth; // Maximale Zellenbreite
ITAASCIITableColumn() {
uiJustify = uiTitleJustify = LEFT;
uiMaxWidth = 0;
}
};
std::vector<ITAASCIITableColumn> m_vColumns;
void splitLines(const std::string& sText, std::vector< std::string >& vsDest);
};
#endif // INCLUDE_WATCHER_ITA_ASCII_TABLE
/*
* ----------------------------------------------------------------
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2016
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
// $Id: ITAAtomicOps.h,v 1.7 2009-01-18 02:04:10 stienen Exp $
#ifndef INCLUDE_WATCHER_ITA_ATOMIC_OPS
#define INCLUDE_WATCHER_ITA_ATOMIC_OPS
#include <ITABaseDefinitions.h>
//! Atomare Leseoperationen
/**
* Diese Funktionen realisieren atomare Leseoperationen.
* Sie lesen den Wert eines Speicherinhaltes und stellen sicher,
* das w�hrend des Lesens kein anderweitiger Schreibzugriff
* auf diesen Speicherinhalt erfolgt.
*/
ITA_BASE_API int atomic_read_int( volatile const int* src );
ITA_BASE_API long atomic_read_long( volatile const long* src );
ITA_BASE_API float atomic_read_float( volatile const float* src );
//extern inline double atomic_read_double(volatile double* dest);
ITA_BASE_API void* atomic_read_ptr( volatile const void** src );
//! Atomare Schreiboperationen
/**
* Diese Funktionen realisieren atomare Schreiboperationen.
* Sie schreiben einen neuen Wert in den gegebenen Speicherinhalt
* und stellen sicher, das w�hrend des Schreibens kein anderweitiger
* Lesezugriff auf diesen Speicherinhalt erfolgt.
*/
ITA_BASE_API void atomic_write_int( volatile int* dest, int value );
ITA_BASE_API void atomic_write_long( volatile long* dest, long value );
ITA_BASE_API void atomic_write_float( volatile float* dest, float value );
//void atomic_write_double(volatile double* dest, double value);
ITA_BASE_API void atomic_write_ptr( volatile void** dest, void* value );
//! Atomares Inkrement und Dekrement (Rückgabe: Wert nach Operation)
ITA_BASE_API int atomic_inc_int( volatile int* dest );
ITA_BASE_API int atomic_dec_int( volatile int* dest );
//! Atomares compare-and-swap (CAS)
/**
* Diese Funktionen realisieren eine der wichtigsten Grundoperationen
* f�r non-blocking Algorithmen: Atomares Compare-and-swap (CAS).
*
* Alle geben 'true' zur�ck falls der Wert ausgetauscht wurde.
* \todo Doku
*/
//bool atomic_CAS_Ptr(void** dest, void* expected_value, void* new_value);
ITA_BASE_API bool atomic_cas_int( volatile int* dest, int expected_value, int new_value );
ITA_BASE_API bool atomic_cas_long( volatile long* dest, long expected_value, long new_value );
//bool atomic_cas_float(volatile float* dest, float expected_value, float new_value);
//bool atomic_cas_double(volatile double* dest, double expected_value, double new_value);
ITA_BASE_API bool atomic_cas_ptr( volatile void** dest, void* expected_value, void* new_value );
// --= Ungetypte Operationen =--
// Atomares Lesen für 32-Bit (4 Bytes)
ITA_BASE_API void atomic_read32( volatile void* src, void* dest );
// Atomares Schreiben für 32-Bit (4 Bytes)
ITA_BASE_API void atomic_write32( volatile void* dest, void* new_value );
// Atomares Compare-And-Swap (CAS) für 32-Bit (4 Bytes) - Rückgabe: true falls ausgetauscht wurde
ITA_BASE_API bool atomic_cas32( volatile void* dest, void* expected_value, void* new_value );
#endif // INCLUDE_WATCHER_ITA_ATOMIC_OPS
/*
* ----------------------------------------------------------------
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2016
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
// $Id: ITAAtomicPrimitives.h,v 1.7 2009-01-18 02:04:10 stienen Exp $
#ifndef INCLUDE_WATCHER_ITA_ATOMIC_PRIMITIVES
#define INCLUDE_WATCHER_ITA_ATOMIC_PRIMITIVES
#include <ITABaseDefinitions.h>
#include <ITAAtomicOps.h>
#include <ITATypes.h>
#include <assert.h>
class ITAAtomicInt
{
public:
//! Standard-Konstruktor
inline ITAAtomicInt() : m_iValue( 0 ) {};
//! Initialisierungs-Konstruktor
inline ITAAtomicInt( int iInitialValue ) : m_iValue( iInitialValue ) {};
//! Getter
inline int get() const {
return atomic_read_int((volatile const int*) &m_iValue);
};
//! Setter
inline void set( const int iValue ) {
atomic_write_int(&m_iValue, iValue);
};
//! Compare-and-swap (CAS)
inline bool cas( int iExpectedValue, int iNewValue ) {
return atomic_cas_int(&m_iValue, iExpectedValue, iNewValue);
};
//! Assignment operator (required for assignments of the form 'ITAAtomicInt = ITAAtomicInt')
inline ITAAtomicInt& operator=( const ITAAtomicInt& iNewValue ) {
set(iNewValue.get());
return *this;
};
//! Assignment operator (required for assignments of the form 'ITAAtomicInt = int')
inline ITAAtomicInt& operator=( const int iNewValue ) {
set(iNewValue);
return *this;
};
//! Cast to int operator (required for assignments of the form 'int = ITAAtomicInt')
inline operator int() const { return get(); }
//! Increment
inline ITAAtomicInt& operator++( ) {
atomic_inc_int(&m_iValue);
return *this;
};
//! Decrement
inline ITAAtomicInt& operator--( ) {
atomic_dec_int(&m_iValue);
return *this;
};
// TODO: Mehr Operatoren nach Bedarf
inline bool operator==( const ITAAtomicInt& rhs ) const { return ( get() == rhs.get() ); };
inline bool operator!=( const ITAAtomicInt& rhs ) const { return ( get() != rhs.get() ); };
inline bool operator==( const int& rhs ) const { return ( get() == rhs ); };
inline bool operator!=( const int& rhs ) const { return ( get() != rhs ); };
private:
volatile int m_iValue;
};
class ITAAtomicLong
{
public:
//! Standard-Konstruktor
inline ITAAtomicLong() : m_lValue( 0 ) {};
//! Initialisierungs-Konstruktor
inline ITAAtomicLong( long lInitialValue ) : m_lValue( lInitialValue ) {};
//! Getter
inline long get() const {
return atomic_read_long((volatile const long*) &m_lValue);
};
//! Setter
inline void set( const long lValue ) {
atomic_write_long((volatile long*) &m_lValue, lValue);
};
//! Compare-and-swap (CAS)
inline bool cas( long lExpectedValue, long lNewValue ) {
return atomic_cas_long((volatile long*) &m_lValue, lExpectedValue, lNewValue);
};
//! Assignment operator (required for assignments of the form 'ITAAtomicLong = ITAAtomicLong')
inline ITAAtomicLong& operator=( const ITAAtomicLong& lNewValue ) {
set(lNewValue.get());
return *this;
};
//! Assignment operator (required for assignments of the form 'ITAAtomicLong = long')
inline ITAAtomicLong& operator=( const long lNewValue ) {
set(lNewValue);
return *this;
};
//! Cast to long operator (required for assignments of the form 'long = ITAAtomicLong')
inline operator long() const { return get(); };
// TODO: Mehr Operatoren nach Bedarf
inline bool operator==( const ITAAtomicLong& rhs ) const { return ( get() == rhs.get() ); };
inline bool operator!=( const ITAAtomicLong& rhs ) const { return ( get() != rhs.get() ); };
inline bool operator==( const long& rhs ) const { return ( get() == rhs ); };
inline bool operator!=( const long& rhs ) const { return ( get() != rhs ); };
inline bool operator==( const int& rhs ) const { return ( get() == rhs ); };
inline bool operator!=( const int& rhs ) const { return ( get() != rhs ); };
private:
volatile long m_lValue;
};
class ITAAtomicBool
{
public:
/*
* Hinweis: Boolesche Typen werden hier mittels Integers umgesetzt
*/
//! Standard-Konstruktor
inline ITAAtomicBool() : m_iState( false ) {};
//! Initialisierungs-Konstruktor
inline ITAAtomicBool( bool bInitialState ) : m_iState( bInitialState ) {};
//! Getter
inline bool get() const {
return (atomic_read_int((volatile const int*) &m_iState) != 0);
};
//! Setter
inline void set( const bool bState ) {
atomic_write_int(&m_iState, bState);
}
//! Compare-and-swap (CAS)
inline bool cas( bool bExpectedState, bool bNewState ) {
return atomic_cas_int(&m_iState, bExpectedState, bNewState);
};
//! Assignment operator (required for assignments of the form 'ITAAtomicBool = ITAAtomicBool')
inline ITAAtomicBool& operator=( const ITAAtomicBool& bNewState ) {
set(bNewState.get());
return *this;
};
//! Assignment operator (required for assignments of the form 'ITAAtomicBool = bool')
inline ITAAtomicBool& operator=( const bool bNewState ) {
set(bNewState);
return *this;
};
//! Cast to int operator (required for assignments of the form 'bool = ITAAtomicBool')
inline operator bool() const { return get(); };