Skip to content

Commit

Permalink
Merge pull request #201 from meyerj/revert-use-cpp11-and-eliminate-bo…
Browse files Browse the repository at this point in the history
…ost-lambda

Revert USE_CPP11 patch and eliminate boost lambda outside scripting
  • Loading branch information
meyerj authored Apr 28, 2017
2 parents 6186784 + f998322 commit d8cf738
Show file tree
Hide file tree
Showing 17 changed files with 44 additions and 119 deletions.
6 changes: 0 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ endif()

PROJECT(orocos-rtt)


SET( RTT_VERSION 2.8.3 )
STRING( REGEX MATCHALL "[0-9]+" RTT_VERSIONS ${RTT_VERSION} )
LIST( GET RTT_VERSIONS 0 RTT_VERSION_MAJOR)
Expand All @@ -43,11 +42,6 @@ if (NOT EXISTS ${PROJ_SOURCE_DIR}/orocos-rtt.cmake)
INCLUDE(${PROJ_SOURCE_DIR}/orocos-rtt.default.cmake)
endif ()

OPTION(USE_CPP11 "Turn on to replace boost::bind with cpp11 bind." OFF)
if(USE_CPP11)
ADD_DEFINITIONS(-DUSE_CPP11)
endif(USE_CPP11)

# On Windows, the default CMAKE_INSTALL_PREFIX is either:
# C:\Program Files\orocos-rtt or C:\Program Files (x86)\orocos-rtt
# However, we want it to be either:
Expand Down
16 changes: 3 additions & 13 deletions rtt/ExecutionEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@
#include "extras/SlaveActivity.hpp"

#include <boost/bind.hpp>
#include <boost/ref.hpp>
#ifndef USE_CPP11
#include <boost/lambda/lambda.hpp>
#include <boost/lambda/bind.hpp>
#endif
#include <functional>
#include <algorithm>

#define ORONUM_EE_MQUEUE_SIZE 100
Expand Down Expand Up @@ -161,8 +155,8 @@ namespace RTT
found = true; // always true in order to be able to quit waitForMessages.
}
virtual void dispose() {}
virtual bool isError() const { return false;}

virtual bool isError() const { return false; }
bool done() const { return !mf->isLoaded() || found; }
};

bool ExecutionEngine::removeFunction( ExecutableInterface* f )
Expand All @@ -182,11 +176,7 @@ namespace RTT
// Running: create message on stack.
RemoveMsg rmsg(f,this);
if ( this->process(&rmsg) )
#ifdef USE_CPP11
this->waitForMessages( ! bind(&ExecutableInterface::isLoaded, f) || bind(&RemoveMsg::found,boost::ref(rmsg)) );
#else
this->waitForMessages( ! lambda::bind(&ExecutableInterface::isLoaded, f) || lambda::bind(&RemoveMsg::found,boost::ref(rmsg)) );
#endif
this->waitForMessages( boost::bind(&RemoveMsg::done, &rmsg) );
if (!rmsg.found)
return false;
}
Expand Down
6 changes: 1 addition & 5 deletions rtt/InputPort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,7 @@ namespace RTT
{
FlowStatus result = NoData;
// read and iterate if necessary.
#ifdef USE_CPP11
cmanager.select_reader_channel( bind( &InputPort::do_read, this, boost::ref(sample), boost::ref(result), _1, _2), copy_old_data );
#else
cmanager.select_reader_channel( boost::bind( &InputPort::do_read, this, boost::ref(sample), boost::ref(result), boost::lambda::_1, boost::lambda::_2), copy_old_data );
#endif
cmanager.select_reader_channel( boost::bind( &InputPort::do_read, this, boost::ref(sample), boost::ref(result), _1, _2 ), copy_old_data );
return result;
}

Expand Down
16 changes: 2 additions & 14 deletions rtt/OutputPort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,9 @@ namespace RTT
has_initial_sample = true;
has_last_written_value = false;

#ifdef USE_CPP11
cmanager.delete_if( bind(
&OutputPort<T>::do_init, this, boost::ref(sample), _1)
);
#else
cmanager.delete_if( boost::bind(
&OutputPort<T>::do_init, this, boost::ref(sample), _1)
&OutputPort<T>::do_init, this, boost::ref(sample), _1 )
);
#endif
}

/**
Expand All @@ -258,15 +252,9 @@ namespace RTT
}
has_last_written_value = keeps_last_written_value;

#ifdef USE_CPP11
cmanager.delete_if( bind(
&OutputPort<T>::do_write, this, boost::ref(sample), _1)
);
#else
cmanager.delete_if( boost::bind(
&OutputPort<T>::do_write, this, boost::ref(sample), boost::lambda::_1)
&OutputPort<T>::do_write, this, boost::ref(sample), _1 )
);
#endif
}

void write(base::DataSourceBase::shared_ptr source)
Expand Down
7 changes: 4 additions & 3 deletions rtt/Service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
#include "TaskContext.hpp"
#include <algorithm>
#include "internal/mystd.hpp"
#include <boost/lambda/lambda.hpp>
#include <boost/lambda/construct.hpp>
#include <algorithm>

namespace RTT {
Expand Down Expand Up @@ -223,7 +221,10 @@ namespace RTT {
simpleoperations.erase(simpleoperations.begin() );
}

for_each(ownedoperations.begin(),ownedoperations.end(), lambda::delete_ptr() );
for( OperationList::const_iterator it = ownedoperations.begin(); it != ownedoperations.end(); ++it )
{
delete *it;
}
ownedoperations.clear();

OperationInterface::clear();
Expand Down
3 changes: 0 additions & 3 deletions rtt/internal/ConnectionManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@
#include <boost/tuple/tuple.hpp>
#include <boost/bind.hpp>
#include <boost/shared_ptr.hpp>
#ifndef USE_CPP11
#include <boost/lambda/lambda.hpp>
#endif

#include <rtt/os/Mutex.hpp>
#include <rtt/os/MutexLock.hpp>
Expand Down
2 changes: 1 addition & 1 deletion rtt/internal/ListLocked.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ namespace RTT
{
if(pred(cur->data))
{
cur = mlist.erase_and_dispose(cur, boost::bind(&ListLocked::give_back, this, ::_1) );
cur = mlist.erase_and_dispose(cur, boost::bind(&ListLocked::give_back, this, _1) );
deleted = true;
}
else
Expand Down
18 changes: 9 additions & 9 deletions rtt/internal/OperationCallerBinder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ namespace RTT
{
template<class M, class O>
boost::function<F> operator()(M m, O o) {
return boost::bind( boost::mem_fn(m), o, ::_1 );
return boost::bind( boost::mem_fn(m), o, _1 );
}
};

Expand All @@ -74,7 +74,7 @@ namespace RTT
{
template<class M, class O>
boost::function<F> operator()(M m, O o) {
return boost::bind( boost::mem_fn(m), o, ::_1, ::_2 );
return boost::bind( boost::mem_fn(m), o, _1, _2 );
}
};

Expand All @@ -83,7 +83,7 @@ namespace RTT
{
template<class M, class O>
boost::function<F> operator()(M m, O o) {
return boost::bind( boost::mem_fn(m), o, ::_1, ::_2, ::_3 );
return boost::bind( boost::mem_fn(m), o, _1, _2, _3 );
}
};

Expand All @@ -92,7 +92,7 @@ namespace RTT
{
template<class M, class O>
boost::function<F> operator()(M m, O o) {
return boost::bind( boost::mem_fn(m), o, ::_1, ::_2, ::_3, ::_4 );
return boost::bind( boost::mem_fn(m), o, _1, _2, _3, _4 );
}
};

Expand All @@ -101,7 +101,7 @@ namespace RTT
{
template<class M, class O>
boost::function<F> operator()(M m, O o) {
return boost::bind( boost::mem_fn(m), o, ::_1, ::_2, ::_3, ::_4, ::_5 );
return boost::bind( boost::mem_fn(m), o, _1, _2, _3, _4, _5 );
}
};

Expand All @@ -110,7 +110,7 @@ namespace RTT
{
template<class M, class O>
boost::function<F> operator()(M m, O o) {
return boost::bind( boost::mem_fn(m), o, ::_1, ::_2, ::_3, ::_4, ::_5, ::_6 );
return boost::bind( boost::mem_fn(m), o, _1, _2, _3, _4, _5, _6 );
}
};

Expand All @@ -119,7 +119,7 @@ namespace RTT
{
template<class M, class O>
boost::function<F> operator()(M m, O o) {
return boost::bind( boost::mem_fn(m), o, ::_1, ::_2, ::_3, ::_4, ::_5, ::_6, ::_7 );
return boost::bind( boost::mem_fn(m), o, _1, _2, _3, _4, _5, _6, _7 );
}
};

Expand All @@ -128,7 +128,7 @@ namespace RTT
{
template<class M, class O>
boost::function<F> operator()(M m, O o) {
return boost::bind( boost::mem_fn(m), o, ::_1, ::_2, ::_3, ::_4, ::_5, ::_6, ::_7, ::_8 );
return boost::bind( boost::mem_fn(m), o, _1, _2, _3, _4, _5, _6, _7, _8 );
}
};

Expand All @@ -137,7 +137,7 @@ namespace RTT
{
template<class M, class O>
boost::function<F> operator()(M m, O o) {
return boost::bind( boost::mem_fn(m), o, ::_1, ::_2, ::_3, ::_4, ::_5, ::_6, ::_7, ::_8, ::_9 );
return boost::bind( boost::mem_fn(m), o, _1, _2, _3, _4, _5, _6, _7, _8, _9 );
}
};

Expand Down
12 changes: 6 additions & 6 deletions rtt/internal/OperationInterfacePartFused.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,15 @@ namespace RTT
#if __cplusplus > 199711L
auto invoke_fused = boost::bind(&FusedMSignal<Signature>::invoke,
boost::make_shared<FusedMSignal<Signature> >(func, SequenceFactory::assignable(args.begin()), subscriber),
boost::arg<1>()
_1
);
typedef typename boost::fusion::result_of::make_unfused< decltype(invoke_fused) >::type unfused_type;
return this->op->signals(boost::forward_adapter<unfused_type>(boost::fusion::make_unfused(invoke_fused)));
#else // __cplusplus > 199711L
return this->op->signals(
boost::fusion::make_unfused(boost::bind(&FusedMSignal<Signature>::invoke,
boost::make_shared<FusedMSignal<Signature> >(func, SequenceFactory::assignable(args.begin()), subscriber),
boost::arg<1>()
_1
)
)
);
Expand All @@ -233,7 +233,7 @@ namespace RTT
return this->op->signals(
boost::fusion::make_unfused_generic(boost::bind(&FusedMSignal<Signature>::invoke,
boost::make_shared<FusedMSignal<Signature> >(func, SequenceFactory::assignable(args.begin()), subscriber),
boost::arg<1>()
_1
)
)
);
Expand Down Expand Up @@ -438,15 +438,15 @@ namespace RTT
#if __cplusplus > 199711L
auto invoke_fused = boost::bind(&FusedMSignal<Signature>::invoke,
boost::make_shared<FusedMSignal<Signature> >(func, SequenceFactory::assignable(args.begin()), subscriber),
boost::arg<1>()
_1
);
typedef typename boost::fusion::result_of::make_unfused< decltype(invoke_fused) >::type unfused_type;
return this->op->signals(boost::forward_adapter<unfused_type>(boost::fusion::make_unfused(invoke_fused)));
#else // __cplusplus > 199711L
return this->op->signals(
boost::fusion::make_unfused(boost::bind(&FusedMSignal<Signature>::invoke,
boost::make_shared<FusedMSignal<Signature> >(func, SequenceFactory::assignable(args.begin()), subscriber),
boost::arg<1>()
_1
)
)
);
Expand All @@ -455,7 +455,7 @@ namespace RTT
return this->op->signals(
boost::fusion::make_unfused_generic(boost::bind(&FusedMSignal<Signature>::invoke,
boost::make_shared<FusedMSignal<Signature> >(func, SequenceFactory::assignable(args.begin()), subscriber),
boost::arg<1>()
_1
)
)
);
Expand Down
9 changes: 4 additions & 5 deletions rtt/internal/SignalBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@


#include "SignalBase.hpp"
#include <boost/lambda/bind.hpp>
#include <boost/bind.hpp>

#ifdef ORO_SIGNAL_USE_LIST_LOCK_FREE
#else
Expand Down Expand Up @@ -232,15 +232,14 @@ namespace RTT {
}

#ifdef ORO_SIGNAL_USE_LIST_LOCK_FREE
// required for GCC 4.0.2
ConnectionBase* getPointer( ConnectionBase::shared_ptr c ) {
return c.get();
static void disconnectImpl( const ConnectionBase::shared_ptr& c ) {
c->disconnect();
}
#endif

void SignalBase::disconnect() {
#ifdef ORO_SIGNAL_USE_LIST_LOCK_FREE
mconnections.apply( boost::lambda::bind(&ConnectionBase::disconnect, boost::lambda::bind( &getPointer, boost::lambda::_1) ) ); // works for any compiler
mconnections.apply( boost::bind(&disconnectImpl, _1 ) );
#else
// avoid invalidating iterator
os::MutexLock lock(m);
Expand Down
34 changes: 14 additions & 20 deletions rtt/internal/signal_template.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@
#include "NA.hpp"

#ifdef ORO_SIGNAL_USE_LIST_LOCK_FREE
#ifndef USE_CPP11
#include <boost/lambda/bind.hpp>
#include <boost/bind.hpp>
#include <boost/lambda/casts.hpp>
#endif
#else
#include "../os/MutexLock.hpp"
#endif
Expand Down Expand Up @@ -105,14 +101,7 @@ namespace RTT {
typedef arg1_type first_argument_type;
typedef arg2_type second_argument_type;
#endif
private:
#ifdef ORO_SIGNAL_USE_LIST_LOCK_FREE
// required for GCC 4.0.2
static connection_impl* applyEmit( connection_t c ) {
return static_cast<connection_impl*> (c.get() );
}
#endif
public:

OROCOS_SIGNAL_N()
{
}
Expand All @@ -132,6 +121,17 @@ namespace RTT {
return Handle(conn);
}

private:
static void emitImpl(const connection_t& c
#if OROCOS_SIGNATURE_NUM_ARGS != 0
, OROCOS_SIGNATURE_PARMS
#endif
)
{
static_cast<connection_impl*>(c.get())->emit(OROCOS_SIGNATURE_ARGS);
}

public:
R emit(OROCOS_SIGNATURE_PARMS)
{
#ifdef ORO_SIGNAL_USE_LIST_LOCK_FREE
Expand All @@ -140,14 +140,8 @@ namespace RTT {
// this code did initially not work under gcc 4.0/ubuntu breezy.
// connection_t::get() const becomes an undefined symbol.
// works under gcc 3.4
#ifdef USE_CPP11
mconnections.apply( bind(&connection_impl::emit,
bind( &applyEmit, _1) // works for any compiler
#else
mconnections.apply( boost::lambda::bind(&connection_impl::emit,
boost::lambda::bind( &applyEmit, boost::lambda::_1) // works for any compiler
//not in gcc 4.0.2: boost::lambda::ll_static_cast<connection_impl*>(boost::lambda::bind(&connection_t::get, boost::lambda::_1))
#endif
mconnections.apply( boost::bind(&OROCOS_SIGNAL_N::emitImpl,
_1
#if OROCOS_SIGNATURE_NUM_ARGS != 0
,OROCOS_SIGNATURE_ARGS
#endif
Expand Down
3 changes: 0 additions & 3 deletions tests/datasource_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,8 @@
#include <boost/serialization/array.hpp>

#include <os/fosi.h>
#include <boost/lambda/lambda.hpp>
#include "datasource_fixture.hpp"

using namespace boost::lambda;

class DataSourceTest
{
public:
Expand Down
Loading

0 comments on commit d8cf738

Please sign in to comment.