Commit ce5ba795 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[MERGE] with default branch

parents a2f0440a 616b2a8a
......@@ -40,6 +40,8 @@ syntax: regexp
^tools/numCores/Makefile$
^tools/numCores/cmake_install.cmake$
# user toolboxes are not versioned
^src/modules/modules-user.toolbox$
syntax: glob
.project
......
See the "doc" directory for more information.
------------------------------------------------------
See the "doc" directory for more information.
------------------------------------------------------
......@@ -12,4 +14,5 @@ Directory Structure:
-src
The sources, i.e. code, icons, ...
-tools
Tools used during development and building (e.g. style checker)
Tools used during development and building
(e.g. style checker)
This directory is intended to serve as the place where one can compile OpenWalnut.
This .README file is in the build directory so that the directory will be recognized and created by mercurial. Only remove it if you know what you are doing or if the behavior of mercurial concerning empty directories has changed.
\ No newline at end of file
......@@ -31,7 +31,7 @@ PROJECT_NAME = OpenWalnut
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = 0.1
PROJECT_NUMBER = 1.0+
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
......@@ -612,10 +612,10 @@ RECURSIVE = YES
# excluded from the INPUT source files. This way you can easily exclude a
# subdirectory from a directory tree whose root is specified with the INPUT tag.
EXCLUDE = src/dataHandler/io/nifti \
EXCLUDE = src/ext \
src/dataHandler/io/nifti \
src/dataHandler/io/biosig \
src/dataHandler/io/biosigWin \
src/dataHandler/io/libeep \
src/common/platformDependent/visualStudio/inttypes.h \
src/modules/lic/fibernavigator \
src/modules/lic/fantom
......
......@@ -31,7 +31,7 @@ PROJECT_NAME = OpenWalnut
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = 0.1
PROJECT_NUMBER = 1.0+
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
......@@ -612,10 +612,10 @@ RECURSIVE = YES
# excluded from the INPUT source files. This way you can easily exclude a
# subdirectory from a directory tree whose root is specified with the INPUT tag.
EXCLUDE = src/dataHandler/io/nifti \
EXCLUDE = src/ext \
src/dataHandler/io/nifti \
src/dataHandler/io/biosig \
src/dataHandler/io/biosigWin \
src/dataHandler/io/libeep \
src/common/platformDependent/visualStudio/inttypes.h \
src/modules/lic/fibernavigator \
src/modules/lic/fantom
......
......@@ -90,6 +90,14 @@ ELSE()
INCLUDE_DIRECTORIES( ${OPENSCENEGRAPH_INCLUDE_DIRS} )
ENDIF()
# some modules need the teem library (http://teem.sourceforge.net/)
find_package( Teem PATHS /usr/local/lib /opt/teem/lib QUIET )
IF( Teem_FOUND ) # we need to add the include path and lib path to allow the compiler and linker to find teem even if it was not installed to
# /usr/local
INCLUDE_DIRECTORIES( ${Teem_INCLUDE_DIRS} )
LINK_DIRECTORIES( ${LINK_DIRECTORIES} ${Teem_LIBRARY_DIRS} )
ENDIF()
# other options:
#---------------
# Set default build type
......@@ -139,15 +147,25 @@ ADD_SUBDIRECTORY( gui )
ADD_SUBDIRECTORY( kernel )
ADD_SUBDIRECTORY( common )
ADD_SUBDIRECTORY( modules )
ADD_SUBDIRECTORY( ext ) # The needed external libraries
#-------------------------------------------------------------------------------------------------------------
# Writes information about the revision of the current code to the file version.h which then gets included by OpenWalnut.cpp
add_custom_command( OUTPUT ${PROJECT_SOURCE_DIR}/version.h
MAIN_DEPENDENCY ${PROJECT_SOURCE_DIR}/../.hg/dirstate
COMMAND hg parents --template '\#define W_VERSION \"{node|short} {rev} {branches} {tags}\"' > ${PROJECT_SOURCE_DIR}/version.h
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT "Creating version.h"
)
IF( NOT CMAKE_GENERATOR MATCHES "Visual Studio" )
add_custom_command( OUTPUT ${PROJECT_SOURCE_DIR}/version.h
MAIN_DEPENDENCY ${PROJECT_SOURCE_DIR}/../.hg/dirstate
COMMAND hg parents --template '\#define W_VERSION \"{node|short} {rev} {branches} {tags}\"' > ${PROJECT_SOURCE_DIR}/version.h
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT "Creating version.h"
)
ELSE()
add_custom_command( OUTPUT ${PROJECT_SOURCE_DIR}/version.h
MAIN_DEPENDENCY ${PROJECT_SOURCE_DIR}/../.hg/dirstate
COMMAND hg parents --template "\"#define W_VERSION \"\"{node|short} {rev} {branches} {tags}\"\"\"" > ${PROJECT_SOURCE_DIR}/version.h
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT "Creating version.h"
)
ENDIF()
# finally, build walnut
ADD_EXECUTABLE( walnut OpenWalnut.cpp version.h )
......@@ -251,7 +269,7 @@ ADD_CUSTOM_TARGET( numCores
FILE( GLOB_RECURSE STYLE_CPP ${PROJECT_SOURCE_DIR}/*.cpp )
FILE( GLOB_RECURSE STYLE_H ${PROJECT_SOURCE_DIR}/*.h )
# Set dirs to exclude from stylecheck
SET( EXCLUDE_DIRS "/dataHandler/io/nifti/;/dataHandler/io/biosig/;/dataHandler/io/biosigWin/;/dataHandler/io/biosig/XMLParser/;/dataHandler/io/biosigWin/XMLParser/;/dataHandler/io/libeep/avr/;/dataHandler/io/libeep/cnt/;/dataHandler/io/libeep/eep/;/common/platformDependent/visualStudio/;/modules/lic/fibernavigator/;/modules/lic/fantom/" )
SET( EXCLUDE_DIRS "/ext/nifti/;/dataHandler/io/biosig/;/dataHandler/io/biosigWin/;/dataHandler/io/biosig/XMLParser/;/dataHandler/io/biosigWin/XMLParser/;/ext/libeep/avr/;/ext/libeep/cnt/;/ext/libeep/eep/;/common/platformDependent/visualStudio/;/modules/lic/fibernavigator/;/modules/lic/fantom/" )
FOREACH( dirname ${EXCLUDE_DIRS} )
FILE( GLOB EXCLUDE_H ${PROJECT_SOURCE_DIR}${dirname}*.h )
FILE( GLOB EXCLUDE_CPP ${PROJECT_SOURCE_DIR}${dirname}*.cpp )
......
......@@ -36,7 +36,7 @@
* \par
* http://www.openwalnut.org
* \par
* Copyright 2009 OpenWalnut Community, BSV\@Uni-Leipzig and CNCF\@MPI-CBS.
* Copyright 2009-2010 OpenWalnut Community, BSV\@Uni-Leipzig and CNCF\@MPI-CBS.
* For more information see http://www.openwalnut.org/copying
*/
......@@ -47,7 +47,7 @@ int main( int argc, char** argv )
{
std::cout << "OpenWalnut ( http://www.openwalnut.org )" << std::endl <<
"Build from: " << W_VERSION << std::endl << std::endl <<
"Copyright (C) 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS\n"
"Copyright (C) 2009-2010 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS\n"
"For more information see http://www.openwalnut.org/copying\n"
"This program comes with ABSOLUTELY NO WARRANTY.\n"
"This is free software, and you are welcome to redistribute it\n"
......
Building OpenWalnut on Windows
******************************
Visual Studio
*************
If you want to build OpenWalnut in 64 Bit with Microsoft tools on a Microsoft Operating System, you have to spend only
$549 (according to Microsoft's Visual Studio 2010 Website on http://www.microsoft.com/germany/visualstudio at
2010/08/08). Of course you can spend even more. For nice features, like an integrated UML Editor, you can spend up
to $11899! And even more exciting is the amazing syntax-highlighting text editor inside the IDE. Wow ... features you
surely won't get with other tools.
But we have to be fair with Microsoft. Instead of providing the 64 Bit compiler in the Visual Studio 2010 Express
Edition, they spend their (and, therefore, your) money for amazing transparent window borders and new
security-anti-virus-über-features like "Are you sure that you are sure that you want me to ask you whether you are sure
to open naked_women.jpg.vba?"-dialogs in their current operating system. But, as we all know, the 64 Bit architecture
gets overrated. AMD has released their Athlon 64 in 2003. No reason for Microsoft to to provide the tools to everybody,
allowing them to make use of it. But who cares. Who needs standards-complying and compatible tools if you can't
install them because the authorization-dialog does not trust you.
We, the OpenWalnut-Team give you a well-meant advice: use the time you would fiddle about getting OpenWalnut compiled in
your Visual Studio for installing one of the numerous free operating systems and for compiling OpenWalnut with the
integrated (free) tools while watching an episode of your favorite TV show.
If you really want to use Visual Studio, try it. We spend a lot of effort to get OpenWalnut "compatible" with Visual
Studio but we can't guarantee that it will compile there. It simply is not made for portable open-source software.
MSYS
****
Have a look at MSYS (http://www.mingw.org/wiki/MSYS). This is a nice alternative and works very good and makes compiling
OpenWalnut very simple.
......@@ -7,14 +7,19 @@ ADD_SUBDIRECTORY( datastructures )
ADD_SUBDIRECTORY( constraints )
ADD_SUBDIRECTORY( math )
ADD_LIBRARY( OWcommon ${COMMON_SRC} ${COMMON_DATASTRUCTURES_SRC} ${COMMON_EXCEPTIONS_SRC} ${MATH_SRC} ${FIBERSIMILARITY_SRC} )
ADD_LIBRARY( OWcommon SHARED ${COMMON_SRC} ${COMMON_DATASTRUCTURES_SRC} ${COMMON_EXCEPTIONS_SRC} ${MATH_SRC} ${FIBERSIMILARITY_SRC} )
TARGET_LINK_LIBRARIES( OWcommon ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} )
# Set the prefix and suffix of dynamically loadable modules to match
# CMAKEs naming of them. The quotes are necessary so the shell doesn't mess
# with these defines.
add_definitions( '-DW_LIB_PREFIX="${CMAKE_SHARED_LIBRARY_PREFIX}"' )
add_definitions( '-DW_LIB_SUFFIX="${CMAKE_SHARED_LIBRARY_SUFFIX}"' )
# with these defines. Unfortunately, the Visual Studio has problems handling
# the quotes on the command line. WSharedLib::getSystemPrefix and
# getSystemSuffix hard codes the right strings for VC.
# Maybe you have to spend another 500 bucks to have your VC support quotes.
IF( NOT CMAKE_GENERATOR MATCHES "Visual Studio" )
add_definitions( '-DW_LIB_PREFIX="${CMAKE_SHARED_LIBRARY_PREFIX}"' )
add_definitions( '-DW_LIB_SUFFIX="${CMAKE_SHARED_LIBRARY_SUFFIX}"' )
ENDIF()
# Unit tests
IF( OW_COMPILE_TESTS )
......
......@@ -28,6 +28,7 @@
#include <string>
#include "WException.h"
#include "WExportCommon.h"
/**
* Implements assertion logic.
......@@ -40,7 +41,7 @@
* \param line The line in the file.
* \param msg An optional message.
*/
void wAssertFailed( std::string const& expression, std::string const& file, std::size_t line, std::string const& msg );
void OWCOMMON_EXPORT wAssertFailed( std::string const& expression, std::string const& file, std::size_t line, std::string const& msg );
//! the actual assertion macro
#define WAssert( e, msg ) ( ( e ) ? ( ( void )0 ) : ( wAssertFailed( #e, __FILE__, __LINE__, msg ) ) )
......
......@@ -31,10 +31,12 @@
#include <string>
#include <vector>
#include "WExportCommon.h"
/**
* Represents a RGBA Color
*/
class WColor
class OWCOMMON_EXPORT WColor
{
public:
......
......@@ -29,11 +29,13 @@
#include <boost/signals2/signal.hpp>
#include <boost/thread.hpp>
#include "WExportCommon.h"
/**
* Class to encapsulate boost::condition_variable_any. You may use it to efficiently wait for events (a condition comes true). It
* is a very simple implementation. It might be extended easily. Timed wait functions and so on.
*/
class WCondition
class OWCOMMON_EXPORT WCondition // NOLINT
{
friend class WCondition_test;
public:
......
......@@ -28,6 +28,7 @@
#include <boost/thread.hpp>
#include "WCondition.h"
#include "WExportCommon.h"
/**
* Implements a WCondition, but can be fired only ONCE. This is useful if you want to have a thread waiting for a condition but
......@@ -36,7 +37,7 @@
* on a mutex. All waiting threads try to get a read lock which is not possible as long it is write-locked. The notify method
* releases the write lock and all waiting threads can continue.
*/
class WConditionOneShot: public WCondition
class OWCOMMON_EXPORT WConditionOneShot: public WCondition
{
friend class WConditionOneShot_test;
public:
......
......@@ -32,13 +32,14 @@
#include <boost/thread.hpp>
#include "WCondition.h"
#include "WExportCommon.h"
/**
* Class allowing multiple conditions to be used for one waiting cycle. Since wait() can not be used for waiting on multiple
* conditions, this class can encapsulate multiple conditions and offer a wait() command to wait for one of them to change its
* state. Please not that this class can also be used as condition.
*/
class WConditionSet: public WCondition
class OWCOMMON_EXPORT WConditionSet: public WCondition
{
friend class WConditionSetTest;
public:
......
......@@ -31,11 +31,12 @@
#include <sstream>
#include "WTerminalColor.h"
#include "WExportCommon.h"
/**
* Basic exception handler.
*/
class WException: public std::exception
class OWCOMMON_EXPORT WException: public std::exception
{
/**
* Only UnitTests are allowed to be a friend of this class.
......
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WEXPORTCOMMON_H
#define WEXPORTCOMMON_H
#ifdef _MSC_VER
#pragma warning( disable: 4251 )
#ifdef OWcommon_EXPORTS
#define OWCOMMON_EXPORT __declspec( dllexport )
#else
#define OWCOMMON_EXPORT __declspec( dllimport )
#endif
#else
#define OWCOMMON_EXPORT
#endif // _MSC_VER
#endif // WEXPORTCOMMON_H
......@@ -29,6 +29,7 @@
#include <boost/signals2/signal.hpp>
#include "WFlag.h"
#include "WExportCommon.h"
/**
* This class helps especially container module programmers to easily synchronize the value of one flag with several other
......@@ -49,7 +50,7 @@
* \param T the encapsulated type inside the flag. I.e. for WFlag< int32_t > use T=int32_t
*/
template < typename T >
class WFlagForwarder
class OWCOMMON_EXPORT WFlagForwarder // NOLINT
{
public:
......
......@@ -23,64 +23,45 @@
//---------------------------------------------------------------------------
#include <algorithm>
#include <iomanip>
#include <numeric>
#include "WAssert.h"
#include "WHistogram.h"
#include "WLimits.h"
#include "WLogger.h"
WHistogram::WHistogram( double min, double max, size_t size )
: m_bins( size, 0 ),
m_min( min ),
m_max( max )
WHistogram::WHistogram( double min, double max, size_t buckets ):
m_minimum( min ),
m_maximum( max ),
m_nbBuckets( buckets )
{
if( min > max )
{
std::swap( m_min, m_max );
std::swap( m_minimum, m_maximum );
}
WAssert( m_bins.size() > 0, "Error: A histogram with a size of 0 does not make any sense" );
m_intervalWidth = std::abs( m_min - m_max ) / m_bins.size();
WAssert( buckets > 0, "Error: A histogram with a size of 0 does not make any sense." );
}
WHistogram::~WHistogram()
WHistogram::WHistogram( const WHistogram& hist ):
m_minimum( hist.m_minimum ),
m_maximum( hist.m_maximum ),
m_nbBuckets( hist.m_nbBuckets )
{
}
void WHistogram::insert( double value )
WHistogram::~WHistogram()
{
if( value > m_max || value < m_min )
{
wlog::warn( "WHistogram" ) << std::scientific << std::setprecision( 16 ) << "Inserted value out of bounds, thread: "
<< value << " as min, resp. max: " << m_min << "," << m_max;
return; // value = ( value > m_max ? m_max : m_min );
}
if( value == m_max )
{
value = m_max - wlimits::DBL_EPS;
}
m_bins.at( static_cast< size_t >( std::abs( value - m_min ) / m_intervalWidth ) )++;
}
size_t WHistogram::binSize() const
size_t WHistogram::size() const
{
return m_bins.size();
return m_nbBuckets;
}
size_t WHistogram::valuesSize() const
double WHistogram::getMinimum() const
{
return std::accumulate( m_bins.begin(), m_bins.end(), 0 );
return m_minimum;
}
size_t WHistogram::operator[]( size_t index ) const
double WHistogram::getMaximum() const
{
if( index >= m_bins.size() )
{
wlog::error( "WHistogram" ) << index << "th interval is not available, there are only: " << m_bins.size();
return 0;
}
return m_bins[ index ];
return m_maximum;
}
......@@ -25,80 +25,115 @@
#ifndef WHISTOGRAM_H
#define WHISTOGRAM_H
#include <vector>
#include <utility>
#include "WExportCommon.h"
/**
* Container which associate values with (uniform width) bins (aka intervals or buckets).
* Container which associate values with (uniform width) bins (aka intervals or buckets). This class implements the abstract interface and
* therefore builds the base class for all histogram classes. The interface also allows programming histogram of different bucket sizes.
*/
class WHistogram
class OWCOMMON_EXPORT WHistogram // NOLINT
{
public:
/**
* Default constructor.
* Default constructor. Creates an empty histogram covering the specified min and max values with the specified number of buckets.
*
* \param min the smallest value
* \param max the largest value
* \param buckets the number of buckets
*/
WHistogram( double min, double max, size_t buckets = 1000 );
/**
* Copy constructor. Creates a deep copy of the specified histogram.
*
* \param min
* \param max
* \param size
* \param hist the histogram to copy.
*/
WHistogram( double min, double max, size_t size = 1000 );
WHistogram( const WHistogram& hist );
/**
* Default destructor.
*/
~WHistogram();
virtual ~WHistogram();
/**
* Inserts a given value within the given range (min, max) into exactly one bin and increment its size.
* Get the count of the specified bucket.
*
* \param index which buckets count is to be returned; starts with 0 which is the bucket containing the smallest values.
*
* \param value Value to insert.
* \return elements in the bucket.
*/
void insert( double value );
virtual size_t operator[]( size_t index ) const = 0;
/**
* Computes number of invervals.
* Get the count of the specified bucket. Testing if the position is valid.
*
* \return Number of intervals.
* \param index which buckets count is to be returned; starts with 0 which is the bucket containing the smallest values.
*
* \return elements in the bucket
*/
size_t binSize() const;
virtual size_t at( size_t index ) const = 0;