Commit 8d66b945 authored by Alexander Wiebel's avatar Alexander Wiebel
Browse files

Merge remote-tracking branch 'origin/442-move-from-boost-to-std'

With merge conflict fixes
parents 46525e18 507cac64
......@@ -37,7 +37,7 @@ WCondition::~WCondition()
void WCondition::wait() const
{
// since Boost 1.54, we need to explicitly lock the mutex prior to wait.
boost::unique_lock<boost::shared_mutex> lock( m_mutex );
std::unique_lock<std::shared_mutex> lock( m_mutex );
m_condition.wait( m_mutex );
}
......
......@@ -25,6 +25,8 @@
#ifndef WCONDITION_H
#define WCONDITION_H
#include <shared_mutex>
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
#include <boost/signals2/signal.hpp>
......@@ -43,12 +45,12 @@ public:
/**
* Shared pointer type for WCondition.
*/
typedef boost::shared_ptr< WCondition > SPtr;
typedef std::shared_ptr< WCondition > SPtr;
/**
* Const shared pointer type for WCondition.
*/
typedef boost::shared_ptr< const WCondition > ConstSPtr;
typedef std::shared_ptr< const WCondition > ConstSPtr;
/**
* Default constructor.
......@@ -103,7 +105,7 @@ protected:
/**
* The mutex used for the condition.
*/
mutable boost::shared_mutex m_mutex;
mutable std::shared_mutex m_mutex;
private:
};
......
......@@ -28,7 +28,7 @@ WConditionOneShot::WConditionOneShot()
: WCondition()
{
// initialize members
m_lock = boost::unique_lock<boost::shared_mutex>( m_mutex );
m_lock = std::unique_lock<std::shared_mutex>( m_mutex );
}
WConditionOneShot::~WConditionOneShot()
......@@ -38,7 +38,7 @@ WConditionOneShot::~WConditionOneShot()
{
m_lock.unlock();
}
catch( const boost::lock_error &e )
catch( const std::system_error &e )
{
// ignore this particular error since it is thrown when the lock is not locked anymore
}
......@@ -46,9 +46,10 @@ WConditionOneShot::~WConditionOneShot()
void WConditionOneShot::wait() const
{
// now we wait until the write lock is released and we can get a read lock
boost::shared_lock<boost::shared_mutex> slock = boost::shared_lock<boost::shared_mutex>( m_mutex );
slock.unlock();
if( m_lock.owns_lock() )
{
m_condition.wait( m_mutex );
}
}
void WConditionOneShot::notify()
......@@ -57,7 +58,7 @@ void WConditionOneShot::notify()
{
m_lock.unlock();
}
catch( const boost::lock_error &e )
catch( const std::system_error &e )
{
// ignore this particular error since it is thrown when the lock is not locked anymore
// because the notify was called multiple times
......
......@@ -25,6 +25,8 @@
#ifndef WCONDITIONONESHOT_H
#define WCONDITIONONESHOT_H
#include <shared_mutex>
#include <boost/thread.hpp>
#include "WCondition.h"
......@@ -65,7 +67,7 @@ protected:
/**
* Locked as long the condition was not fired.
*/
boost::unique_lock<boost::shared_mutex> m_lock;
std::unique_lock<std::shared_mutex> m_lock;
private:
};
......
......@@ -36,7 +36,7 @@ WConditionSet::WConditionSet():
WConditionSet::~WConditionSet()
{
// get write lock
boost::unique_lock<boost::shared_mutex> lock = boost::unique_lock<boost::shared_mutex>( m_conditionSetLock );
std::unique_lock<std::shared_mutex> lock = std::unique_lock<std::shared_mutex>( m_conditionSetLock );
// clean conditions list
// NOTE: we need to disconnect here.
......@@ -49,10 +49,10 @@ WConditionSet::~WConditionSet()
lock.unlock();
}
void WConditionSet::add( boost::shared_ptr< WCondition > condition )
void WConditionSet::add( std::shared_ptr< WCondition > condition )
{
// get write lock
boost::unique_lock<boost::shared_mutex> lock = boost::unique_lock<boost::shared_mutex>( m_conditionSetLock );
std::unique_lock<std::shared_mutex> lock = std::unique_lock<std::shared_mutex>( m_conditionSetLock );
if( !m_conditionSet.count( condition ) )
{
......@@ -64,10 +64,10 @@ void WConditionSet::add( boost::shared_ptr< WCondition > condition )
lock.unlock();
}
void WConditionSet::remove( boost::shared_ptr< WCondition > condition )
void WConditionSet::remove( std::shared_ptr< WCondition > condition )
{
// get write lock
boost::unique_lock<boost::shared_mutex> lock = boost::unique_lock<boost::shared_mutex>( m_conditionSetLock );
std::unique_lock<std::shared_mutex> lock = std::unique_lock<std::shared_mutex>( m_conditionSetLock );
// get the element
ConditionConnectionMap::iterator it = m_conditionSet.find( condition );
......
......@@ -26,6 +26,7 @@
#define WCONDITIONSET_H
#include <map>
#include <shared_mutex>
#include <utility>
#include <boost/shared_ptr.hpp>
......@@ -46,12 +47,12 @@ public:
/**
* Shared pointer to instance of this class.
*/
typedef boost::shared_ptr< WConditionSet > SPtr;
typedef std::shared_ptr< WConditionSet > SPtr;
/**
* Shared pointer to const instance of this class.
*/
typedef boost::shared_ptr< const WConditionSet > ConstSPtr;
typedef std::shared_ptr< const WConditionSet > ConstSPtr;
/**
* Default constructor.
......@@ -69,14 +70,14 @@ public:
*
* \param condition the condition to add.
*/
virtual void add( boost::shared_ptr< WCondition > condition );
virtual void add( std::shared_ptr< WCondition > condition );
/**
* Removes the specified condition. As add() this immediately takes effect on running wait() calls.
*
* \param condition the condition to remove
*/
virtual void remove( boost::shared_ptr< WCondition > condition );
virtual void remove( std::shared_ptr< WCondition > condition );
/**
* Wait for the condition. Sets the calling thread asleep. If the condition set is resetable, this will return immediately
......@@ -129,7 +130,7 @@ protected:
* We need to keep track of the connections a condition has made since boost::function objects do not provide a == operator and can therefore
* not easily be removed from a signals by signal.desconnect( functor ).
*/
typedef std::map< boost::shared_ptr< WCondition >, boost::signals2::connection > ConditionConnectionMap;
typedef std::map< std::shared_ptr< WCondition >, boost::signals2::connection > ConditionConnectionMap;
/**
* Set of conditions to be waited for.
......@@ -139,12 +140,12 @@ protected:
/**
* Each condition has a connection.
*/
typedef std::pair< boost::shared_ptr< WCondition >, boost::signals2::connection > ConditionConnectionPair;
typedef std::pair< std::shared_ptr< WCondition >, boost::signals2::connection > ConditionConnectionPair;
/**
* Lock used for thread-safe writing to the condition set.
*/
boost::shared_mutex m_conditionSetLock;
std::shared_mutex m_conditionSetLock;
/**
* Notifier function getting notified whenever a condition got fired.
......
......@@ -25,6 +25,8 @@
#ifndef WCOUNTER_H
#define WCOUNTER_H
#include <shared_mutex>
#include <boost/thread.hpp>
/**
......@@ -50,7 +52,7 @@ public:
*/
int operator++ ()
{
boost::unique_lock< boost::shared_mutex > lock( m_counterMutex );
std::unique_lock< std::shared_mutex > lock( m_counterMutex );
return ++m_counter;
}
......@@ -61,7 +63,7 @@ public:
*/
int operator-- ()
{
boost::unique_lock< boost::shared_mutex > lock( m_counterMutex );
std::unique_lock< std::shared_mutex > lock( m_counterMutex );
return --m_counter;
}
......@@ -72,7 +74,7 @@ public:
*/
int operator() () const
{
boost::shared_lock< boost::shared_mutex > lock( m_counterMutex );
boost::shared_lock< std::shared_mutex > lock( m_counterMutex );
return m_counter;
}
......@@ -83,7 +85,7 @@ public:
*/
int reset()
{
boost::unique_lock< boost::shared_mutex > lock( m_counterMutex );
std::unique_lock< std::shared_mutex > lock( m_counterMutex );
int tmp = m_counter;
m_counter = 0;
return tmp;
......@@ -101,7 +103,7 @@ private:
WCounter operator= ( WCounter& /* count */ );
//! A mutex to protect the counter from concurrent updates.
mutable boost::shared_mutex m_counterMutex;
mutable std::shared_mutex m_counterMutex;
//! The counter.
int m_counter;
......
......@@ -43,14 +43,14 @@ public:
typedef T ValueType;
/**
* Convenience typedef for a boost::shared_ptr.
* Convenience typedef for a std::shared_ptr.
*/
typedef boost::shared_ptr< WFlag< T > > SPtr;
typedef std::shared_ptr< WFlag< T > > SPtr;
/**
* Convenience typedef for a boost::shared_ptr. Const.
* Convenience typedef for a std::shared_ptr. Const.
*/
typedef boost::shared_ptr< const WFlag< T > > ConstSPtr;
typedef std::shared_ptr< const WFlag< T > > ConstSPtr;
/**
* Constructor. Uses a given condition to realize the wait/notify functionality. By using this constructor, the specified
......@@ -70,7 +70,7 @@ public:
* \note condition can also be a WConditionOneShot.
* \param initial the initial value of this flag.
*/
WFlag( boost::shared_ptr< WCondition > condition, const T& initial );
WFlag( std::shared_ptr< WCondition > condition, const T& initial );
/**
* Copy constructor. Creates a deep copy of this property. As boost::signals2 and condition variables are non-copyable, new instances get
......@@ -147,7 +147,7 @@ public:
*
* \return the condition
*/
boost::shared_ptr< WCondition > getCondition();
std::shared_ptr< WCondition > getCondition();
/**
* Returns the condition denoting a value change. In contrast to getCondition, this condition fires regardless of notification is suppressed
......@@ -155,7 +155,7 @@ public:
*
* \return the condition denoting a value change.
*/
boost::shared_ptr< WCondition > getValueChangeCondition();
std::shared_ptr< WCondition > getValueChangeCondition();
/**
* Determines whether the specified value is acceptable. In WFlags, this always returns true. To modify the behaviour,
......@@ -188,13 +188,13 @@ protected:
/**
* The condition to be used for waiting/notifying. Please note, that it gets deleted during destruction.
*/
boost::shared_ptr< WCondition > m_condition;
std::shared_ptr< WCondition > m_condition;
/**
* This condition is fired whenever the value changes. In contrast to m_condition, this also fires if set() is called with
* suppressNotification=true.
*/
boost::shared_ptr< WCondition > m_valueChangeCondition;
std::shared_ptr< WCondition > m_valueChangeCondition;
/**
* The flag value.
......@@ -216,17 +216,17 @@ typedef WFlag< bool > WBoolFlag;
template < typename T >
WFlag< T >::WFlag( WCondition* condition, const T& initial ):
m_condition( boost::shared_ptr< WCondition >( condition ) ),
m_valueChangeCondition( boost::shared_ptr< WCondition >( new WCondition() ) ),
m_condition( std::shared_ptr< WCondition >( condition ) ),
m_valueChangeCondition( std::shared_ptr< WCondition >( new WCondition() ) ),
m_flag( initial ),
m_changed( true )
{
}
template < typename T >
WFlag< T >::WFlag( boost::shared_ptr< WCondition > condition, const T& initial ):
WFlag< T >::WFlag( std::shared_ptr< WCondition > condition, const T& initial ):
m_condition( condition ),
m_valueChangeCondition( boost::shared_ptr< WCondition >( new WCondition() ) ),
m_valueChangeCondition( std::shared_ptr< WCondition >( new WCondition() ) ),
m_flag( initial ),
m_changed( true )
{
......@@ -234,8 +234,8 @@ WFlag< T >::WFlag( boost::shared_ptr< WCondition > condition, const T& initial )
template < typename T >
WFlag< T >::WFlag( const WFlag& from ):
m_condition( boost::shared_ptr< WCondition >( new WCondition() ) ),
m_valueChangeCondition( boost::shared_ptr< WCondition >( new WCondition() ) ),
m_condition( std::shared_ptr< WCondition >( new WCondition() ) ),
m_valueChangeCondition( std::shared_ptr< WCondition >( new WCondition() ) ),
m_flag( from.m_flag ),
m_changed( from.m_changed )
{
......@@ -315,13 +315,13 @@ bool WFlag< T >::set( const T& value, bool suppressNotification )
}
template < typename T >
boost::shared_ptr< WCondition > WFlag< T >::getCondition()
std::shared_ptr< WCondition > WFlag< T >::getCondition()
{
return m_condition;
}
template < typename T >
boost::shared_ptr< WCondition > WFlag< T >::getValueChangeCondition()
std::shared_ptr< WCondition > WFlag< T >::getValueChangeCondition()
{
return m_valueChangeCondition;
}
......
......@@ -58,7 +58,7 @@ public:
*
* \param source the property to be used as reference. All other properties will be synced with this one.
*/
explicit WFlagForwarder( boost::shared_ptr< WFlag< T > > source );
explicit WFlagForwarder( std::shared_ptr< WFlag< T > > source );
/**
* Destructor.
......@@ -71,13 +71,13 @@ public:
*
* \param to the property to sync with source.
*/
void forward( boost::shared_ptr< WFlag< T > > to );
void forward( std::shared_ptr< WFlag< T > > to );
protected:
/**
* The source property to which all other properties are synced to.
*/
boost::shared_ptr< WFlag< T > > m_source;
std::shared_ptr< WFlag< T > > m_source;
/**
* The signal fired by m_source upon value change
......@@ -112,7 +112,7 @@ private:
};
template < typename T >
WFlagForwarder< T >::WFlagForwarder( boost::shared_ptr< WFlag< T > > source ):
WFlagForwarder< T >::WFlagForwarder( std::shared_ptr< WFlag< T > > source ):
m_source( source )
{
// connect the source's change signal
......@@ -128,7 +128,7 @@ WFlagForwarder< T >::~WFlagForwarder()
}
template < typename T >
void WFlagForwarder< T >::forward( boost::shared_ptr< WFlag< T > > to )
void WFlagForwarder< T >::forward( std::shared_ptr< WFlag< T > > to )
{
to->set( m_source->get() );
......
......@@ -82,13 +82,13 @@ void WHierarchicalTreeFibers::addCluster( size_t cluster1, size_t cluster2, size
++m_clusterCount;
}
boost::shared_ptr< std::vector<bool> > WHierarchicalTreeFibers::getOutputBitfield( size_t cluster )
std::shared_ptr< std::vector<bool> > WHierarchicalTreeFibers::getOutputBitfield( size_t cluster )
{
boost::shared_ptr< std::vector< bool > > bf;
std::shared_ptr< std::vector< bool > > bf;
// only a single fiber selected
if( cluster < m_leafCount )
{
bf = boost::shared_ptr< std::vector< bool > >( new std::vector< bool >( m_leafCount, false ) );
bf = std::shared_ptr< std::vector< bool > >( new std::vector< bool >( m_leafCount, false ) );
( *bf )[cluster] = true;
}
else
......@@ -98,7 +98,7 @@ boost::shared_ptr< std::vector<bool> > WHierarchicalTreeFibers::getOutputBitfiel
return bf;
}
bf = boost::shared_ptr< std::vector< bool > >( new std::vector< bool >( m_leafCount, false ) );
bf = std::shared_ptr< std::vector< bool > >( new std::vector< bool >( m_leafCount, false ) );
std::vector<size_t> fibers = m_containsLeafes[cluster];
for( size_t i = 0; i < fibers.size(); ++i )
......@@ -111,12 +111,12 @@ boost::shared_ptr< std::vector<bool> > WHierarchicalTreeFibers::getOutputBitfiel
return bf;
}
boost::shared_ptr< std::vector<bool> >WHierarchicalTreeFibers::getOutputBitfield( std::vector<size_t>clusters )
std::shared_ptr< std::vector<bool> >WHierarchicalTreeFibers::getOutputBitfield( std::vector<size_t>clusters )
{
boost::shared_ptr< std::vector< bool > > bf;
std::shared_ptr< std::vector< bool > > bf;
// only a single fiber selected
bf = boost::shared_ptr< std::vector< bool > >( new std::vector< bool >( m_leafCount, false ) );
bf = std::shared_ptr< std::vector< bool > >( new std::vector< bool >( m_leafCount, false ) );
for( size_t k = 0; k < clusters.size(); ++k )
{
......
......@@ -76,7 +76,7 @@ public:
* \param cluster
* \return shared pointer to the bitfield
*/
boost::shared_ptr< std::vector<bool> >getOutputBitfield( size_t cluster );
std::shared_ptr< std::vector<bool> >getOutputBitfield( size_t cluster );
/**
* generates a bitfield where for every leaf in the selected cluster the value is true, false otherwise
......@@ -84,7 +84,7 @@ public:
* \param clusters
* \return shared pointer to the bitfield
*/
boost::shared_ptr< std::vector<bool> >getOutputBitfield( std::vector<size_t>clusters );
std::shared_ptr< std::vector<bool> >getOutputBitfield( std::vector<size_t>clusters );
/**
* finds clusters that match a given ROI up to a certain percentage
......@@ -108,18 +108,18 @@ public:
* setter
* \param bitfield
*/
void setRoiBitField( boost::shared_ptr< std::vector<bool> > bitfield );
void setRoiBitField( std::shared_ptr< std::vector<bool> > bitfield );
protected:
private:
/**
* stores a pointer to the bitfield by the current roi setting
*/
boost::shared_ptr< std::vector<bool> > m_roiSelection;
std::shared_ptr< std::vector<bool> > m_roiSelection;
};
inline void WHierarchicalTreeFibers::setRoiBitField( boost::shared_ptr< std::vector<bool> > bitfield )
inline void WHierarchicalTreeFibers::setRoiBitField( std::shared_ptr< std::vector<bool> > bitfield )
{
m_roiSelection = bitfield;
}
......
......@@ -45,7 +45,7 @@ public:
/**
* Convenience type for a shared_ptr on this type.
*/
typedef boost::shared_ptr< WHistogram2D > SPtr;
typedef std::shared_ptr< WHistogram2D > SPtr;
/**
* Creates a two dimensional histogram field, bounded by the given limits, containing the demanded number of buckets in each dimension.
......
......@@ -34,7 +34,7 @@
#include "WItemSelection.h"
WItemSelection::WItemSelection() :
WSharedSequenceContainer< std::vector< boost::shared_ptr< WItemSelectionItem > > >()
WSharedSequenceContainer< std::vector< std::shared_ptr< WItemSelectionItem > > >()
{
// initialize members
}
......@@ -102,10 +102,10 @@ WItemSelector WItemSelection::getSelector( size_t item )
void WItemSelection::addItem( std::string name, std::string description, const char** icon )
{
push_back( boost::shared_ptr< WItemSelectionItem >( new WItemSelectionItem( name, description, icon ) ) );
push_back( std::shared_ptr< WItemSelectionItem >( new WItemSelectionItem( name, description, icon ) ) );
}
void WItemSelection::addItem( boost::shared_ptr< WItemSelectionItem > item )
void WItemSelection::addItem( std::shared_ptr< WItemSelectionItem > item )
{
push_back( item );
}
......
......@@ -46,20 +46,20 @@ class WItemSelector;
* not implement any function that might change the item list, use the provided ones. If the item list changes, existing selectors get invalid
* automatically using the change condition of the inherited WSharedSequenceContainer.
*/
class WItemSelection: public boost::enable_shared_from_this< WItemSelection >,
public WSharedSequenceContainer< std::vector< boost::shared_ptr< WItemSelectionItem > > >
class WItemSelection: public std::enable_shared_from_this< WItemSelection >,
public WSharedSequenceContainer< std::vector< std::shared_ptr< WItemSelectionItem > > >
{
friend class WItemSelector; //!< for proper locking and unlocking
public:
/**
* Convenience typedef for a boost::shared_ptr< WItemSelection >
* Convenience typedef for a std::shared_ptr< WItemSelection >
*/
typedef boost::shared_ptr< WItemSelection > SPtr;
typedef std::shared_ptr< WItemSelection > SPtr;
/**
* Convenience typedef for a boost::shared_ptr< const WItemSelection >
* Convenience typedef for a std::shared_ptr< const WItemSelection >
*/
typedef boost::shared_ptr< const WItemSelection > ConstSPtr;
typedef std::shared_ptr< const WItemSelection > ConstSPtr;
/**
* Default constructor.
......@@ -117,9 +117,9 @@ public:
*
* \return the Item.
*/
static boost::shared_ptr< WItemSelectionItem > Item( std::string name, std::string description = "", const char** icon = NULL )
static std::shared_ptr< WItemSelectionItem > Item( std::string name, std::string description = "", const char** icon = NULL )
{
return boost::shared_ptr< WItemSelectionItem >( new WItemSelectionItem( name, description, icon ) );
return std::shared_ptr< WItemSelectionItem >( new WItemSelectionItem( name, description, icon ) );
}
/**
......@@ -137,7 +137,7 @@ public:
*
* \param item WItemSelectionItem or derivation which should be add.
*/
void addItem( boost::shared_ptr< WItemSelectionItem > item );
void addItem( std::shared_ptr< WItemSelectionItem > item );
private:
};
......
......@@ -38,12 +38,12 @@ public:
/**
* Abbreviation for a shared pointer.
*/
typedef boost::shared_ptr< WItemSelectionItem > SPtr;
typedef std::shared_ptr< WItemSelectionItem > SPtr;
/**
* Abbreviation for a const shared pointer.
*/
typedef boost::shared_ptr< const WItemSelectionItem > ConstSPtr;
typedef std::shared_ptr< const WItemSelectionItem > ConstSPtr;
/**
* Constructs a new item with the specified values.
......
......@@ -46,12 +46,12 @@ public:
/**
* Abbreviation for a shared pointer.
*/
typedef boost::shared_ptr< WItemSelectionItemTyped< T > > SPtr;
typedef std::shared_ptr< WItemSelectionItemTyped< T > > SPtr;
/**
* Abbreviation for a const shared pointer.
*/
typedef boost::shared_ptr< const WItemSelectionItemTyped< T > > ConstSPtr;
typedef std::shared_ptr< const WItemSelectionItemTyped< T > > ConstSPtr;
/**
* The type of the value stored in here.
......
......@@ -30,7 +30,7 @@
#include "WItemSelector.h"
WItemSelector::WItemSelector( boost::shared_ptr< WItemSelection > selection, IndexList selected ):
WItemSelector::WItemSelector( std::shared_ptr< WItemSelection > selection, IndexList selected ):
m_selection( selection ),
m_selected( selected ),
m_invalidateSignalConnection(),
......@@ -143,12 +143,12 @@ size_t WItemSelector::size() const
return m_selected.size();
}
const boost::shared_ptr< WItemSelectionItem > WItemSelector::atAll( size_t index ) const
const std::shared_ptr< WItemSelectionItem > WItemSelector::atAll( size_t index ) const
{