Commit 95e0b58d authored by ledig's avatar ledig

[FIX] Merge conflicts Win compile and Style

parent 61641d85
//---------------------------------------------------------------------------
//
// 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/>.
//
//---------------------------------------------------------------------------
#include <string>
#include <boost/lexical_cast.hpp>
#include "WAssert.h"
void wAssertFailed( std::string const& expression, std::string const& file, std::size_t line, std::string const& msg )
{
#ifdef WASSERT_AS_CASSERT
std::cerr << "Assertion failed: " << expression << " (in file " << file << " at line " << line << ")";
if( !msg.empty() )
{
std::cerr << ", Message: " << msg;
}
std::cerr << std::endl;
abort();
#else
std::string s = "Assertion failed: " + expression + " (in file " + file + " at line " + boost::lexical_cast< std::string >( line ) + ")";
if( !msg.empty() )
{
s += ", Message: " + msg;
}
throw WException( s );
#endif
}
//---------------------------------------------------------------------------
//
// 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/>.
//
//---------------------------------------------------------------------------
#include <string>
#include <boost/lexical_cast.hpp>
#include "WAssert.h"
void wAssertFailed( std::string const& expression, std::string const& file, std::size_t line, std::string const& msg )
{
#ifdef WASSERT_AS_CASSERT
std::cerr << "Assertion failed: " << expression << " (in file " << file << " at line " << line << ")";
if( !msg.empty() )
{
std::cerr << ", Message: " << msg;
}
std::cerr << std::endl;
abort();
#else
std::string s = "Assertion failed: " + expression + " (in file " + file + " at line " + boost::lexical_cast< std::string >( line ) + ")";
if( !msg.empty() )
{
s += ", Message: " + msg;
}
throw WException( s );
#endif
}
//---------------------------------------------------------------------------
//
// 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/>.
//
//---------------------------------------------------------------------------
#include "WBoundingBox.h"
//---------------------------------------------------------------------------
//
// 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/>.
//
//---------------------------------------------------------------------------
#include "WBoundingBox.h"
This diff is collapsed.
//---------------------------------------------------------------------------
//
// 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/>.
//
//---------------------------------------------------------------------------
#include "WCondition.h"
WCondition::WCondition()
{
// initialize members
}
WCondition::~WCondition()
{
// cleanup
}
void WCondition::wait() const
{
m_condition.wait( m_mutex );
}
void WCondition::notify()
{
signal_ConditionFired();
m_condition.notify_all();
}
boost::signals2::connection WCondition::subscribeSignal( t_ConditionNotifierType notifier )
{
return signal_ConditionFired.connect( notifier );
}
//---------------------------------------------------------------------------
//
// 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/>.
//
//---------------------------------------------------------------------------
#include "WCondition.h"
WCondition::WCondition()
{
// initialize members
}
WCondition::~WCondition()
{
// cleanup
}
void WCondition::wait() const
{
m_condition.wait( m_mutex );
}
void WCondition::notify()
{
signal_ConditionFired();
m_condition.notify_all();
}
boost::signals2::connection WCondition::subscribeSignal( t_ConditionNotifierType notifier )
{
return signal_ConditionFired.connect( notifier );
}
//---------------------------------------------------------------------------
//
// 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/>.
//
//---------------------------------------------------------------------------
#include "WConditionOneShot.h"
WConditionOneShot::WConditionOneShot()
: WCondition()
{
// initialize members
m_lock = boost::unique_lock<boost::shared_mutex>( m_mutex );
}
WConditionOneShot::~WConditionOneShot()
{
// win crashes here sometimes
#ifndef _MSC_VER
// cleanup
try
{
m_lock.unlock();
}
catch( const boost::lock_error &e )
{
// ignore this particular error since it is thrown when the lock is not locked anymore
}
#endif
}
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();
}
void WConditionOneShot::notify()
{
try
{
m_lock.unlock();
}
catch( const boost::lock_error &e )
{
// ignore this particular error since it is thrown when the lock is not locked anymore
// because the notify was called multiple times
}
WCondition::notify();
}
//---------------------------------------------------------------------------
//
// 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/>.
//
//---------------------------------------------------------------------------
#include "WConditionOneShot.h"
WConditionOneShot::WConditionOneShot()
: WCondition()
{
// initialize members
m_lock = boost::unique_lock<boost::shared_mutex>( m_mutex );
}
WConditionOneShot::~WConditionOneShot()
{
// win crashes here sometimes
#ifndef _MSC_VER
// cleanup
try
{
m_lock.unlock();
}
catch( const boost::lock_error &e )
{
// ignore this particular error since it is thrown when the lock is not locked anymore
}
#endif
}
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();
}
void WConditionOneShot::notify()
{
try
{
m_lock.unlock();
}
catch( const boost::lock_error &e )
{
// ignore this particular error since it is thrown when the lock is not locked anymore
// because the notify was called multiple times
}
WCondition::notify();
}
//---------------------------------------------------------------------------
//
// 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/>.
//
//---------------------------------------------------------------------------
#include "WConditionSet.h"
WConditionSet::WConditionSet():
WCondition(),
m_resetable( false ),
m_autoReset( false ),
m_fired( false ),
m_notifier( boost::bind( &WConditionSet::conditionFired, this ) )
{
}
WConditionSet::~WConditionSet()
{
// clean conditions list
m_conditionSet.clear();
}
void WConditionSet::add( boost::shared_ptr< WCondition > condition )
{
// get write lock
boost::unique_lock<boost::shared_mutex> lock = boost::unique_lock<boost::shared_mutex>( m_conditionSetLock );
if ( !m_conditionSet.count( condition ) )
{
// create a new pair, the condition and its connection object.
// this is needed since remove needs the connection to disconnect the notifier again
m_conditionSet.insert( ConditionConnectionPair( condition, condition->subscribeSignal( m_notifier ) ) );
}
lock.unlock();
}
void WConditionSet::remove( boost::shared_ptr< WCondition > condition )
{
// get write lock
boost::unique_lock<boost::shared_mutex> lock = boost::unique_lock<boost::shared_mutex>( m_conditionSetLock );
// get the element
ConditionConnectionMap::iterator it = m_conditionSet.find( condition );
if ( it != m_conditionSet.end() )
{
( *it ).second.disconnect();
m_conditionSet.erase( it );
}
lock.unlock();
}
void WConditionSet::conditionFired()
{
m_fired = true;
notify();
}
void WConditionSet::wait() const
{
if ( !m_resetable || !m_fired )
{
WCondition::wait();
}
if ( m_autoReset )
{