SMACC2
Loading...
Searching...
No Matches
smacc2::introspection::StateReactorHandler Class Reference

#include <smacc_state_info.hpp>

Collaboration diagram for smacc2::introspection::StateReactorHandler:
Collaboration graph

Public Member Functions

 StateReactorHandler (rclcpp::Node::SharedPtr nh)
 
void configureStateReactor (std::shared_ptr< smacc2::StateReactor > sr)
 
template<typename TEv >
void addInputEvent ()
 
template<typename TEv >
void setOutputEvent ()
 

Public Attributes

std::weak_ptr< smacc2::introspection::SmaccStateReactorInfo > srInfo_
 

Private Attributes

std::vector< StateReactorCallbackFunctor > callbacks_
 
rclcpp::Logger logger_
 

Detailed Description

Definition at line 94 of file smacc_state_info.hpp.

Constructor & Destructor Documentation

◆ StateReactorHandler()

smacc2::introspection::StateReactorHandler::StateReactorHandler ( rclcpp::Node::SharedPtr nh)
inlineexplicit

Definition at line 103 of file smacc_state_info.hpp.

104 : logger_(nh ? nh->get_logger() : rclcpp::get_logger("StateReactorHandler"))
105 {
106 }

Member Function Documentation

◆ addInputEvent()

template<typename TEv >
void smacc2::introspection::StateReactorHandler::addInputEvent ( )

Definition at line 81 of file smacc_state_reactor_impl.hpp.

82{
83 StateReactorCallbackFunctor functor;
84 functor.fn = [this](std::shared_ptr<smacc2::StateReactor> sr)
85 {
86 auto srInfo = srInfo_.lock();
87 RCLCPP_INFO(
88 logger_, "[%s] State Reactor adding input event: %s",
89 srInfo ? srInfo->stateReactorType->getFullName().c_str() : "?",
90 demangledTypeName<TEv>().c_str());
91 sr->addInputEvent<TEv>();
92 };
93
94 this->callbacks_.push_back(functor);
95
96 auto evtype = TypeInfo::getFromStdTypeInfo(typeid(TEv));
97 auto evinfo = std::make_shared<SmaccEventInfo>(evtype);
98 EventLabel<TEv>(evinfo->label);
99
100 // The info owns this handler and is alive for as long as the static reactor map holds it.
101 auto srInfo = srInfo_.lock();
102 if (srInfo != nullptr)
103 {
104 srInfo->sourceEventTypes.push_back(evinfo);
105 }
106}
std::vector< StateReactorCallbackFunctor > callbacks_
std::weak_ptr< smacc2::introspection::SmaccStateReactorInfo > srInfo_
static TypeInfo::Ptr getFromStdTypeInfo(const std::type_info &tid)
std::enable_if< HasEventLabel< T >::value, void >::type EventLabel(std::string &label)
std::string demangledTypeName()

References callbacks_, smacc2::introspection::demangledTypeName(), smacc2::introspection::EventLabel(), smacc2::introspection::StateReactorCallbackFunctor::fn, smacc2::introspection::TypeInfo::getFromStdTypeInfo(), logger_, and srInfo_.

Here is the call graph for this function:

◆ configureStateReactor()

void smacc2::introspection::StateReactorHandler::configureStateReactor ( std::shared_ptr< smacc2::StateReactor > sr)

Definition at line 62 of file state_reactor.cpp.

63{
64 for (auto callback : this->callbacks_)
65 {
66 callback.fn(sr);
67 }
68}

References callbacks_.

◆ setOutputEvent()

template<typename TEv >
void smacc2::introspection::StateReactorHandler::setOutputEvent ( )

Definition at line 109 of file smacc_state_reactor_impl.hpp.

110{
111 StateReactorCallbackFunctor functor;
112 functor.fn = [this](std::shared_ptr<smacc2::StateReactor> sr)
113 {
114 auto srInfo = srInfo_.lock();
115 RCLCPP_INFO(
116 logger_, "[%s] State Reactor setting output event: %s",
117 srInfo ? srInfo->stateReactorType->getFullName().c_str() : "?",
118 demangledTypeName<TEv>().c_str());
119 sr->setOutputEvent<TEv>();
120 };
121
122 this->callbacks_.push_back(functor);
123}

References callbacks_, smacc2::introspection::demangledTypeName(), smacc2::introspection::StateReactorCallbackFunctor::fn, logger_, and srInfo_.

Here is the call graph for this function:

Member Data Documentation

◆ callbacks_

std::vector<StateReactorCallbackFunctor> smacc2::introspection::StateReactorHandler::callbacks_
private

Definition at line 97 of file smacc_state_info.hpp.

Referenced by addInputEvent(), configureStateReactor(), and setOutputEvent().

◆ logger_

rclcpp::Logger smacc2::introspection::StateReactorHandler::logger_
private

Definition at line 120 of file smacc_state_info.hpp.

Referenced by addInputEvent(), and setOutputEvent().

◆ srInfo_

std::weak_ptr<smacc2::introspection::SmaccStateReactorInfo> smacc2::introspection::StateReactorHandler::srInfo_

Definition at line 117 of file smacc_state_info.hpp.

Referenced by addInputEvent(), and setOutputEvent().


The documentation for this class was generated from the following files: