Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ SmaccSignal is a communication mechanism (template wrapper around boost::signals
### Signal Connection Lifetime Management
Signal connections are managed through the state machine's
createSignalConnection() which:
1. Creates boost::signals2 connections between signal sources and
1. Creates smacc2::SmaccSignalConnection connections between signal sources and
callbacks
2. Tracks connections by object pointer
3. Automatically disconnects when objects are destroyed via
Expand Down
6 changes: 3 additions & 3 deletions smacc2/include/smacc2/callback_counter_semaphore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
******************************************************************************************************************/

#pragma once
#include <boost/signals2.hpp>
#include <condition_variable>
#include <iostream>
#include <mutex>
#include <rclcpp/rclcpp.hpp>
#include <smacc2/smacc_signal.hpp>
#include <thread>

namespace smacc2
Expand All @@ -38,13 +38,13 @@ class CallbackCounterSemaphore

void finalize();

void addConnection(boost::signals2::connection conn);
void addConnection(smacc2::SmaccSignalConnection conn);

private:
int count_;
std::mutex mutex_;
std::condition_variable cv_;
std::vector<boost::signals2::connection> connections_;
std::vector<smacc2::SmaccSignalConnection> connections_;
bool finalized = false;
std::string name_;
};
Expand Down
20 changes: 10 additions & 10 deletions smacc2/include/smacc2/client_bases/smacc_action_client_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,62 +155,62 @@ class SmaccActionClientBase : public ISmaccActionClient
}

template <typename T>
boost::signals2::connection onSucceeded(void (T::*callback)(WrappedResult &), T * object)
smacc2::SmaccSignalConnection onSucceeded(void (T::*callback)(WrappedResult &), T * object)
{
return this->getStateMachine()->createSignalConnection(onSucceeded_, callback, object);
}

template <typename T>
boost::signals2::connection onSucceeded(std::function<void(WrappedResult &)> callback)
smacc2::SmaccSignalConnection onSucceeded(std::function<void(WrappedResult &)> callback)
{
return this->getStateMachine()->createSignalConnection(onSucceeded_, callback);
}

template <typename T>
boost::signals2::connection onAborted(void (T::*callback)(WrappedResult &), T * object)
smacc2::SmaccSignalConnection onAborted(void (T::*callback)(WrappedResult &), T * object)
{
return this->getStateMachine()->createSignalConnection(onAborted_, callback, object);
}

template <typename T>
boost::signals2::connection onAborted(std::function<void(WrappedResult &)> callback)
smacc2::SmaccSignalConnection onAborted(std::function<void(WrappedResult &)> callback)
{
return this->getStateMachine()->createSignalConnection(onAborted_, callback);
}

template <typename T>
boost::signals2::connection onCancelled(void (T::*callback)(WrappedResult &), T * object)
smacc2::SmaccSignalConnection onCancelled(void (T::*callback)(WrappedResult &), T * object)
{
return this->getStateMachine()->createSignalConnection(onCancelled_, callback, object);
}

template <typename T>
boost::signals2::connection onCancelled(std::function<void(WrappedResult &)> callback)
smacc2::SmaccSignalConnection onCancelled(std::function<void(WrappedResult &)> callback)
{
return this->getStateMachine()->createSignalConnection(onCancelled_, callback);
}

/*
template <typename T>
boost::signals2::connection onPreempted(void (T::*callback)(WrappedResult &), T *object)
smacc2::SmaccSignalConnection onPreempted(void (T::*callback)(WrappedResult &), T *object)
{
return this->getStateMachine()->createSignalConnection(onPreempted_, callback, object);
}

template <typename T>
boost::signals2::connection onPreempted(std::function<void(WrappedResult &)> callback)
smacc2::SmaccSignalConnection onPreempted(std::function<void(WrappedResult &)> callback)
{
return this->getStateMachine()->createSignalConnection(onPreempted_, callback);
}

template <typename T>
boost::signals2::connection onRejected(void (T::*callback)(WrappedResult &), T *object)
smacc2::SmaccSignalConnection onRejected(void (T::*callback)(WrappedResult &), T *object)
{
return this->getStateMachine()->createSignalConnection(onRejected_, callback, object);
}

template <typename T>
boost::signals2::connection onRejected(std::function<void(WrappedResult &)> callback)
smacc2::SmaccSignalConnection onRejected(std::function<void(WrappedResult &)> callback)
{
return this->getStateMachine()->createSignalConnection(onRejected_, callback);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class SmaccServiceServerClient : public smacc2::ISmaccClient
onServiceRequestReceived_;

template <typename T>
boost::signals2::connection onServiceRequestReceived(
smacc2::SmaccSignalConnection onServiceRequestReceived(
void (T::*callback)(
const std::shared_ptr<typename TService::Request>,
std::shared_ptr<typename TService::Response>),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ class SmaccSubscriberClient : public smacc2::ISmaccClient
std::function<void(const MessageType &)> postInitialMessageEvent;

template <typename T>
boost::signals2::connection onMessageReceived(
smacc2::SmaccSignalConnection onMessageReceived(
void (T::*callback)(const MessageType &), T * object)
{
return this->getStateMachine()->createSignalConnection(onMessageReceived_, callback, object);
}

template <typename T>
boost::signals2::connection onFirstMessageReceived(
smacc2::SmaccSignalConnection onFirstMessageReceived(
void (T::*callback)(const MessageType &), T * object)
{
return this->getStateMachine()->createSignalConnection(
Expand Down
4 changes: 2 additions & 2 deletions smacc2/include/smacc2/client_behaviors/cb_sequence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ class CbSequence : public smacc2::SmaccAsyncClientBehavior
void recursiveConsumeNext();

std::list<std::function<std::shared_ptr<smacc2::SmaccAsyncClientBehavior>()>> sequenceNodes_;
boost::signals2::connection conn_;
boost::signals2::connection conn2_;
smacc2::SmaccSignalConnection conn_;
smacc2::SmaccSignalConnection conn2_;

std::shared_ptr<smacc2::SmaccAsyncClientBehavior> bh_;
std::atomic<int> consume_{0};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,25 +199,25 @@ class CpActionClient : public smacc2::ISmaccComponent

// Signal connection methods
template <typename T>
boost::signals2::connection onSucceeded(void (T::*callback)(const WrappedResult &), T * object)
smacc2::SmaccSignalConnection onSucceeded(void (T::*callback)(const WrappedResult &), T * object)
{
return this->getStateMachine()->createSignalConnection(onActionSucceeded_, callback, object);
}

template <typename T>
boost::signals2::connection onAborted(void (T::*callback)(const WrappedResult &), T * object)
smacc2::SmaccSignalConnection onAborted(void (T::*callback)(const WrappedResult &), T * object)
{
return this->getStateMachine()->createSignalConnection(onActionAborted_, callback, object);
}

template <typename T>
boost::signals2::connection onCancelled(void (T::*callback)(const WrappedResult &), T * object)
smacc2::SmaccSignalConnection onCancelled(void (T::*callback)(const WrappedResult &), T * object)
{
return this->getStateMachine()->createSignalConnection(onActionCancelled_, callback, object);
}

template <typename T>
boost::signals2::connection onFeedback(void (T::*callback)(const Feedback &), T * object)
smacc2::SmaccSignalConnection onFeedback(void (T::*callback)(const Feedback &), T * object)
{
return this->getStateMachine()->createSignalConnection(onActionFeedback_, callback, object);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class CpRos2Timer : public smacc2::ISmaccComponent
}

template <typename T>
boost::signals2::connection onTimerTick(void (T::*callback)(), T * object)
smacc2::SmaccSignalConnection onTimerTick(void (T::*callback)(), T * object)
{
return this->getStateMachine()->createSignalConnection(onTimerTick_, callback, object);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ class CpServiceClient : public smacc2::ISmaccComponent
* @return Signal connection handle
*/
template <typename T>
boost::signals2::connection onResponse(void (T::*callback)(const SharedResponse &), T * object)
smacc2::SmaccSignalConnection onResponse(void (T::*callback)(const SharedResponse &), T * object)
{
return this->getStateMachine()->createSignalConnection(onServiceResponse_, callback, object);
}
Expand All @@ -341,7 +341,7 @@ class CpServiceClient : public smacc2::ISmaccComponent
* @return Signal connection handle
*/
template <typename T>
boost::signals2::connection onRequestSent(void (T::*callback)(), T * object)
smacc2::SmaccSignalConnection onRequestSent(void (T::*callback)(), T * object)
{
return this->getStateMachine()->createSignalConnection(onServiceRequestSent_, callback, object);
}
Expand All @@ -355,7 +355,7 @@ class CpServiceClient : public smacc2::ISmaccComponent
* @return Signal connection handle
*/
template <typename T>
boost::signals2::connection onFailure(void (T::*callback)(), T * object)
smacc2::SmaccSignalConnection onFailure(void (T::*callback)(), T * object)
{
return this->getStateMachine()->createSignalConnection(onServiceFailure_, callback, object);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ class CpTopicSubscriber : public smacc2::ISmaccComponent

// signal subscription method. This signal will be triggered when the first message is received
template <typename T>
boost::signals2::connection onMessageReceived(
smacc2::SmaccSignalConnection onMessageReceived(
void (T::*callback)(const MessageType &), T * object)
{
return this->getStateMachine()->createSignalConnection(onMessageReceived_, callback, object);
}

// signal subscription method. This signal will be triggered when the first message is received
template <typename T>
boost::signals2::connection onFirstMessageReceived(
smacc2::SmaccSignalConnection onFirstMessageReceived(
void (T::*callback)(const MessageType &), T * object)
{
return this->getStateMachine()->createSignalConnection(
Expand Down
1 change: 0 additions & 1 deletion smacc2/include/smacc2/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include <boost/function.hpp>
#include <boost/intrusive_ptr.hpp>
#include <boost/mpl/list.hpp>
#include <boost/signals2.hpp>

#include <mutex>
#include <rclcpp/rclcpp.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,21 @@ void SmaccAsyncClientBehavior::onStateOrthogonalAllocation()
}

template <typename TCallbackMethod, typename T>
boost::signals2::connection SmaccAsyncClientBehavior::onSuccess(
smacc2::SmaccSignalConnection SmaccAsyncClientBehavior::onSuccess(
TCallbackMethod callback, T * object)
{
return this->getStateMachine()->createSignalConnection(onSuccess_, callback, object);
}

template <typename TCallbackMethod, typename T>
boost::signals2::connection SmaccAsyncClientBehavior::onFinished(
smacc2::SmaccSignalConnection SmaccAsyncClientBehavior::onFinished(
TCallbackMethod callback, T * object)
{
return this->getStateMachine()->createSignalConnection(onFinished_, callback, object);
}

template <typename TCallbackMethod, typename T>
boost::signals2::connection SmaccAsyncClientBehavior::onFailure(
smacc2::SmaccSignalConnection SmaccAsyncClientBehavior::onFailure(
TCallbackMethod callback, T * object)
{
return this->getStateMachine()->createSignalConnection(onFailure_, callback, object);
Expand Down
14 changes: 7 additions & 7 deletions smacc2/include/smacc2/impl/smacc_state_machine_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ template <int arity>
struct Bind
{
template <typename TSmaccSignal, typename TMemberFunctionPrototype, typename TSmaccObjectType>
boost::signals2::connection bindaux(
smacc2::SmaccSignalConnection bindaux(
TSmaccSignal & signal, TMemberFunctionPrototype callback, TSmaccObjectType * object,
std::shared_ptr<CallbackCounterSemaphore> callbackCounter);
};
Expand All @@ -328,7 +328,7 @@ template <>
struct Bind<1>
{
template <typename TSmaccSignal, typename TMemberFunctionPrototype, typename TSmaccObjectType>
boost::signals2::connection bindaux(
smacc2::SmaccSignalConnection bindaux(
TSmaccSignal & signal, TMemberFunctionPrototype callback, TSmaccObjectType * object,
std::shared_ptr<CallbackCounterSemaphore> callbackCounter)
{
Expand All @@ -353,7 +353,7 @@ template <>
struct Bind<2>
{
template <typename TSmaccSignal, typename TMemberFunctionPrototype, typename TSmaccObjectType>
boost::signals2::connection bindaux(
smacc2::SmaccSignalConnection bindaux(
TSmaccSignal & signal, TMemberFunctionPrototype callback, TSmaccObjectType * object,
std::shared_ptr<CallbackCounterSemaphore> callbackCounter)
{
Expand All @@ -377,7 +377,7 @@ template <>
struct Bind<3>
{
template <typename TSmaccSignal, typename TMemberFunctionPrototype, typename TSmaccObjectType>
boost::signals2::connection bindaux(
smacc2::SmaccSignalConnection bindaux(
TSmaccSignal & signal, TMemberFunctionPrototype callback, TSmaccObjectType * object,
std::shared_ptr<CallbackCounterSemaphore> callbackCounter)
{
Expand All @@ -401,7 +401,7 @@ template <>
struct Bind<4>
{
template <typename TSmaccSignal, typename TMemberFunctionPrototype, typename TSmaccObjectType>
boost::signals2::connection bindaux(
smacc2::SmaccSignalConnection bindaux(
TSmaccSignal & signal, TMemberFunctionPrototype callback, TSmaccObjectType * object,
std::shared_ptr<CallbackCounterSemaphore> callbackCounter)
{
Expand All @@ -424,7 +424,7 @@ struct Bind<4>
using namespace smacc2::utils;

template <typename TSmaccSignal, typename TMemberFunctionPrototype, typename TSmaccObjectType>
boost::signals2::connection ISmaccStateMachine::createSignalConnection(
smacc2::SmaccSignalConnection ISmaccStateMachine::createSignalConnection(
TSmaccSignal & signal, TMemberFunctionPrototype callback, TSmaccObjectType * object)
{
std::lock_guard<std::recursive_mutex> lock(m_mutex_);
Expand All @@ -439,7 +439,7 @@ boost::signals2::connection ISmaccStateMachine::createSignalConnection(

typedef decltype(callback) ft;
Bind<boost::function_types::function_arity<ft>::value> binder;
boost::signals2::connection connection;
smacc2::SmaccSignalConnection connection;

// long life-time objects
if (
Expand Down
6 changes: 3 additions & 3 deletions smacc2/include/smacc2/smacc_asynchronous_client_behavior.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ class SmaccAsyncClientBehavior : public ISmaccClientBehavior
virtual ~SmaccAsyncClientBehavior();

template <typename TCallback, typename T>
boost::signals2::connection onSuccess(TCallback callback, T * object);
smacc2::SmaccSignalConnection onSuccess(TCallback callback, T * object);

template <typename TCallback, typename T>
boost::signals2::connection onFinished(TCallback callback, T * object);
smacc2::SmaccSignalConnection onFinished(TCallback callback, T * object);

template <typename TCallback, typename T>
boost::signals2::connection onFailure(TCallback callback, T * object);
smacc2::SmaccSignalConnection onFailure(TCallback callback, T * object);

void requestForceFinish();

Expand Down
3 changes: 3 additions & 0 deletions smacc2/include/smacc2/smacc_signal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#pragma once

#include <boost/any.hpp>
#include <boost/signals2/connection.hpp>
#include <boost/signals2/signal.hpp>

namespace smacc2
Expand All @@ -29,6 +30,8 @@ using namespace boost;
using namespace boost::signals2;
using namespace boost::signals2::detail;

typedef boost::signals2::connection SmaccSignalConnection;

template <
typename Signature,
typename Combiner = optional_last_value<typename boost::function_traits<Signature>::result_type>,
Expand Down
4 changes: 1 addition & 3 deletions smacc2/include/smacc2/smacc_state_machine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class ISmaccStateMachine
std::shared_ptr<smacc2_msgs::srv::SmaccGetTransitionHistory::Response> res);

template <typename TSmaccSignal, typename TMemberFunctionPrototype, typename TSmaccObjectType>
boost::signals2::connection createSignalConnection(
smacc2::SmaccSignalConnection createSignalConnection(
TSmaccSignal & signal, TMemberFunctionPrototype callback, TSmaccObjectType * object);

void disconnectSmaccSignalObject(void * object);
Expand Down Expand Up @@ -199,8 +199,6 @@ class ISmaccStateMachine
// orthogonals
std::map<std::string, std::shared_ptr<smacc2::ISmaccOrthogonal>> orthogonals_;

std::vector<boost::signals2::scoped_connection> longLivedSignalConnections_;

protected:
std::shared_ptr<SmaccStateMachineInfo> stateMachineInfo_;

Expand Down
3 changes: 1 addition & 2 deletions smacc2/src/smacc2/callback_counter_semaphore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* Authors: Pablo Inigo Blasco, Brett Aldrich
*
*****************************************************************************************************************/
#include <boost/signals2.hpp>
#include <condition_variable>
#include <iostream>
#include <mutex>
Expand Down Expand Up @@ -88,7 +87,7 @@ void CallbackCounterSemaphore::finalize()
name_.c_str(), (long)this);
}

void CallbackCounterSemaphore::addConnection(boost::signals2::connection conn)
void CallbackCounterSemaphore::addConnection(smacc2::SmaccSignalConnection conn)
{
std::unique_lock<std::mutex> lock(mutex_);

Expand Down
Loading