SMACC2
Loading...
Searching...
No Matches
Classes | Typedefs | Enumerations | Functions | Variables
smacc2::introspection Namespace Reference

Classes

struct  add_type_wrapper
 
struct  AddSubState
 
struct  AddTransition
 
struct  CheckType
 
struct  ClientBehaviorInfoEntry
 
struct  EventGeneratorCallbackFunctor
 
class  EventGeneratorHandler
 
class  HasAutomaticTransitionTag
 
class  HasAutomaticTransitionType
 
class  HasEventLabel
 
class  HasOnDefinition
 
struct  SmaccEventGeneratorInfo
 
struct  SmaccEventInfo
 
class  SmaccStateInfo
 
class  SmaccStateMachineInfo
 
struct  SmaccStateReactorInfo
 
struct  SmaccTransitionInfo
 
struct  StateReactorCallbackFunctor
 
class  StateReactorHandler
 
struct  type_
 
class  TypeInfo
 
struct  typelist
 
struct  WalkStatesExecutor
 

Typedefs

typedef std::allocator< boost::statechart::none > SmaccAllocator
 
typedef boost::mpl::list< SUCCESS, ABORT, CANCEL, CONTINUELOOP, ENDLOOPDEFAULT_TRANSITION_TYPES
 

Enumerations

enum class  SmaccStateType { SUPERSTATE = 2 , STATE = 1 , SUPERSTATE_ROUTINE = 1 }
 

Functions

void transitionInfoToMsg (const SmaccTransitionInfo &transition, smacc2_msgs::msg::SmaccTransition &transitionMsg)
 
template<class T >
auto optionalNodeHandle (std::shared_ptr< T > &obj) -> T *
 
template<class T >
auto optionalNodeHandle (boost::intrusive_ptr< T > &obj) -> T *
 
template<class T >
auto optionalNodeHandle (T *obj) -> T *
 
std::string demangleSymbol (const std::string &name)
 
std::string demangleSymbol (const char *name)
 
template<typename T >
std::string demangleSymbol ()
 
template<class T >
std::string demangledTypeName ()
 
std::string demangleType (const std::type_info *tinfo)
 
std::string demangleType (const std::type_info &tinfo)
 
template<typename T >
std::enable_if< HasEventLabel< T >::value, void >::type EventLabel (std::string &label)
 
template<typename T >
std::enable_if<!HasEventLabel< T >::value, void >::type EventLabel (std::string &label)
 
template<typename T >
std::enable_if< HasAutomaticTransitionTag< T >::value, void >::type automaticTransitionTag (std::string &transition_name)
 
template<typename T >
std::enable_if<!HasAutomaticTransitionTag< T >::value, void >::type automaticTransitionTag (std::string &transition_name)
 
template<typename T >
std::enable_if< HasAutomaticTransitionType< T >::value, void >::type automaticTransitionType (std::string &transition_type)
 
template<typename T >
std::enable_if<!HasAutomaticTransitionType< T >::value, void >::type automaticTransitionType (std::string &transition_type)
 
template<typename TTransition >
static std::string getTransitionType ()
 
template<typename T >
disable_if< boost::mpl::is_sequence< T > >::type processSubState (std::shared_ptr< SmaccStateInfo > &parentState)
 
template<typename T >
enable_if< boost::mpl::is_sequence< T > >::type processSubState (std::shared_ptr< SmaccStateInfo > &parentState)
 
template<typename T >
enable_if< boost::mpl::is_sequence< T > >::type processTransitions (std::shared_ptr< SmaccStateInfo > &sourceState)
 
template<typename Ev , typename Dst , typename Tag >
void processTransition (smacc2::Transition< Ev, boost::statechart::deep_history< Dst >, Tag > *, std::shared_ptr< SmaccStateInfo > &sourceState)
 
template<typename Ev , typename Dst , typename Tag >
void processTransition (smacc2::Transition< Ev, Dst, Tag > *t, std::shared_ptr< SmaccStateInfo > &sourceState)
 
template<typename Ev , typename Dst , typename Tag >
void processTransitionAux (smacc2::Transition< Ev, Dst, Tag > *, std::shared_ptr< SmaccStateInfo > &sourceState, bool history, TypeInfo::Ptr &transitionTypeInfo)
 
template<typename Ev , typename Dst >
void processTransition (statechart::transition< Ev, Dst > *, std::shared_ptr< SmaccStateInfo > &sourceState)
 
template<typename Ev >
void processTransition (statechart::custom_reaction< Ev > *, std::shared_ptr< SmaccStateInfo > &sourceState)
 
template<typename T >
disable_if< boost::mpl::is_sequence< T > >::type processTransitions (std::shared_ptr< SmaccStateInfo > &sourceState)
 
template<typename T >
std::enable_if< HasOnDefinition< T >::value, void >::type CallOnDefinition ()
 
template<typename T >
std::enable_if<!HasOnDefinition< T >::value, void >::type CallOnDefinition ()
 
bool replace (std::string &str, const std::string &from, const std::string &to)
 
std::string replace_back (std::string roottype, std::vector< std::pair< std::string, std::string > > &orderedtypesdict)
 

Variables

rclcpp::Node::SharedPtr globalNh_
 

Typedef Documentation

◆ DEFAULT_TRANSITION_TYPES

Definition at line 223 of file introspection.hpp.

◆ SmaccAllocator

typedef std::allocator<boost::statechart::none> smacc2::introspection::SmaccAllocator

Definition at line 52 of file introspection.hpp.

Enumeration Type Documentation

◆ SmaccStateType

Enumerator
SUPERSTATE 
STATE 
SUPERSTATE_ROUTINE 

Definition at line 155 of file smacc_state_info.hpp.

Function Documentation

◆ automaticTransitionTag() [1/2]

template<typename T >
std::enable_if< HasAutomaticTransitionTag< T >::value, void >::type smacc2::introspection::automaticTransitionTag ( std::string &  transition_name)

Definition at line 174 of file introspection.hpp.

176{
177 transition_name = T::getDefaultTransitionTag();
178}

◆ automaticTransitionTag() [2/2]

template<typename T >
std::enable_if<!HasAutomaticTransitionTag< T >::value, void >::type smacc2::introspection::automaticTransitionTag ( std::string &  transition_name)

Definition at line 181 of file introspection.hpp.

183{
184 transition_name = "";
185}

◆ automaticTransitionType() [1/2]

template<typename T >
std::enable_if< HasAutomaticTransitionType< T >::value, void >::type smacc2::introspection::automaticTransitionType ( std::string &  transition_type)

Definition at line 208 of file introspection.hpp.

210{
211 transition_type = T::getDefaultTransitionType();
212}

◆ automaticTransitionType() [2/2]

template<typename T >
std::enable_if<!HasAutomaticTransitionType< T >::value, void >::type smacc2::introspection::automaticTransitionType ( std::string &  transition_type)

Definition at line 215 of file introspection.hpp.

217{
218 transition_type = demangledTypeName<DEFAULT>();
219}

◆ CallOnDefinition() [1/2]

template<typename T >
std::enable_if< HasOnDefinition< T >::value, void >::type smacc2::introspection::CallOnDefinition ( )

Definition at line 348 of file smacc_state_machine_info.hpp.

349{
350 /* something when T has toString ... */
351 RCLCPP_INFO_STREAM(
352 globalNh_->get_logger(), "EXECUTING ONDEFINITION: " << demangleSymbol(typeid(T).name()));
353 T::staticConfigure();
354}
rclcpp::Node::SharedPtr globalNh_
Definition: reflection.cpp:28
std::string demangleSymbol(const std::string &name)

References demangleSymbol(), and globalNh_.

Here is the call graph for this function:

◆ CallOnDefinition() [2/2]

template<typename T >
std::enable_if<!HasOnDefinition< T >::value, void >::type smacc2::introspection::CallOnDefinition ( )

Definition at line 357 of file smacc_state_machine_info.hpp.

358{
359 RCLCPP_INFO_STREAM(
360 globalNh_->get_logger(),
361 "static OnDefinition: dont exist for " << demangleSymbol(typeid(T).name()));
362 /* something when T has toString ... */
363}

References demangleSymbol(), and globalNh_.

Here is the call graph for this function:

◆ demangledTypeName()

template<class T >
std::string smacc2::introspection::demangledTypeName ( )
inline

Definition at line 101 of file introspection.hpp.

102{
103 return demangleSymbol(typeid(T).name());
104}

References demangleSymbol().

Here is the call graph for this function:

◆ demangleSymbol() [1/3]

template<typename T >
std::string smacc2::introspection::demangleSymbol ( )
inline

Definition at line 95 of file introspection.hpp.

96{
97 return demangleSymbol(typeid(T).name());
98}

References demangleSymbol().

Referenced by smacc2::introspection::SmaccStateMachineInfo::assembleSMStructureMessage(), CallOnDefinition(), demangledTypeName(), demangleSymbol(), demangleType(), smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::entryStateInternal(), smacc2::ISmaccState::getClassName(), smacc2::introspection::SmaccStateInfo::getDemangledFullName(), cl_multirole_sensor::CbDefaultMultiRoleSensorBehavior< ClientType >::getEventLabel(), smacc2::introspection::SmaccEventInfo::getEventSourceName(), smacc2::introspection::SmaccEventInfo::getEventTypeName(), smacc2::introspection::TypeInfo::getFromStdTypeInfo(), smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::getFullName(), smacc2::ISmaccComponent::getName(), smacc2::ISmaccClient::getName(), smacc2::ISmaccClientBehavior::getName(), smacc2::ISmaccOrthogonal::getName(), smacc2::introspection::SmaccEventInfo::getOrthogonalName(), smacc2::ISmaccStateMachine::getStateMachineName(), smacc2::ISmaccStateMachine::mapBehavior(), smacc2::ISmaccStateMachine::notifyOnStateEntryEnd(), smacc2::ISmaccStateMachine::notifyOnStateEntryStart(), smacc2::ISmaccStateMachine::notifyOnStateExited(), smacc2::ISmaccStateMachine::notifyOnStateExitting(), smacc2::state_reactors::SrAllEventsGo::onEventNotified(), smacc2::state_reactors::SrEventCountdown::onEventNotified(), smacc2::client_bases::SmaccActionClientBase< ActionType >::onInitialize(), cl_keyboard::ClKeyboard::postKeyEvent(), cl_keyboard::CbDefaultKeyboardBehavior::postKeyEvent(), smacc2::client_bases::SmaccActionClientBase< ActionType >::postResultEvent(), processTransition(), processTransitionAux(), smacc2::ISmaccState::requiresClient(), and smacc2::ISmaccStateMachine::requiresComponent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ demangleSymbol() [2/3]

std::string smacc2::introspection::demangleSymbol ( const char *  name)
inline

Definition at line 76 of file introspection.hpp.

77{
78#if (__GNUC__ && __cplusplus && __GNUC__ >= 3)
79 int status;
80 char * res = abi::__cxa_demangle(name, 0, 0, &status);
81 if (res)
82 {
83 const std::string demangled_name(res);
84 std::free(res);
85 return demangled_name;
86 }
87 // Demangling failed, fallback to mangled name
88 return std::string(name);
89#else
90 return std::string(name);
91#endif
92}

◆ demangleSymbol() [3/3]

std::string smacc2::introspection::demangleSymbol ( const std::string &  name)
inline

Definition at line 74 of file introspection.hpp.

74{ return demangleSymbol(name.c_str()); }

References demangleSymbol().

Here is the call graph for this function:

◆ demangleType() [1/2]

std::string smacc2::introspection::demangleType ( const std::type_info &  tinfo)
inline

Definition at line 111 of file introspection.hpp.

112{
113 return demangleSymbol(tinfo.name());
114}

References demangleSymbol().

Here is the call graph for this function:

◆ demangleType() [2/2]

std::string smacc2::introspection::demangleType ( const std::type_info *  tinfo)
inline

◆ EventLabel() [1/2]

template<typename T >
std::enable_if< HasEventLabel< T >::value, void >::type smacc2::introspection::EventLabel ( std::string &  label)

Definition at line 142 of file introspection.hpp.

143{
144 label = T::getEventLabel();
145}

◆ EventLabel() [2/2]

template<typename T >
std::enable_if<!HasEventLabel< T >::value, void >::type smacc2::introspection::EventLabel ( std::string &  label)

Definition at line 148 of file introspection.hpp.

149{
150 label = "";
151}

◆ getTransitionType()

template<typename TTransition >
static std::string smacc2::introspection::getTransitionType ( )
static

Definition at line 259 of file introspection.hpp.

260{
261 std::string output;
262 CheckType<TTransition> op(&output);
263 using boost::mpl::_1;
264 using wrappedList = typename boost::mpl::transform<DEFAULT_TRANSITION_TYPES, _1>::type;
265
266 boost::mpl::for_each<wrappedList>(op);
267 return output;
268}

◆ optionalNodeHandle() [1/3]

template<class T >
auto smacc2::introspection::optionalNodeHandle ( boost::intrusive_ptr< T > &  obj) -> T *

Definition at line 62 of file introspection.hpp.

63{
64 //return obj->getNode();
65 return obj.get();
66}

◆ optionalNodeHandle() [2/3]

template<class T >
auto smacc2::introspection::optionalNodeHandle ( std::shared_ptr< T > &  obj) -> T *

Definition at line 55 of file introspection.hpp.

56{
57 //return obj->getNode();
58 return obj.get;
59}

◆ optionalNodeHandle() [3/3]

template<class T >
auto smacc2::introspection::optionalNodeHandle ( T *  obj) -> T *

Definition at line 69 of file introspection.hpp.

70{
71 return obj;
72}

◆ processSubState() [1/2]

template<typename T >
disable_if< boost::mpl::is_sequence< T > >::type smacc2::introspection::processSubState ( std::shared_ptr< SmaccStateInfo > &  parentState)

◆ processSubState() [2/2]

template<typename T >
enable_if< boost::mpl::is_sequence< T > >::type smacc2::introspection::processSubState ( std::shared_ptr< SmaccStateInfo > &  parentState)

Definition at line 149 of file smacc_state_machine_info.hpp.

151{
152 using boost::mpl::_1;
153 using wrappedList = typename boost::mpl::transform<T, add_type_wrapper<_1>>::type;
154 boost::mpl::for_each<wrappedList>(AddSubState(parentState));
155}

◆ processTransition() [1/4]

template<typename Ev , typename Dst , typename Tag >
void smacc2::introspection::processTransition ( smacc2::Transition< Ev, boost::statechart::deep_history< Dst >, Tag > *  ,
std::shared_ptr< SmaccStateInfo > &  sourceState 
)

Definition at line 172 of file smacc_state_machine_info.hpp.

175{
176 auto transitionTypeInfo = TypeInfo::getTypeInfoFromType<
178 smacc2::Transition<Ev, Dst, Tag> * mock = nullptr;
179 processTransitionAux(mock, sourceState, true, transitionTypeInfo);
180}
void processTransitionAux(smacc2::Transition< Ev, Dst, Tag > *, std::shared_ptr< SmaccStateInfo > &sourceState, bool history, TypeInfo::Ptr &transitionTypeInfo)

References smacc2::introspection::TypeInfo::getTypeInfoFromType(), and processTransitionAux().

Referenced by processTransitions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processTransition() [2/4]

template<typename Ev , typename Dst , typename Tag >
void smacc2::introspection::processTransition ( smacc2::Transition< Ev, Dst, Tag > *  t,
std::shared_ptr< SmaccStateInfo > &  sourceState 
)

Definition at line 183 of file smacc_state_machine_info.hpp.

185{
186 auto transitionTypeInfo = TypeInfo::getTypeInfoFromType<smacc2::Transition<Ev, Dst, Tag>>();
187 RCLCPP_INFO(
188 globalNh_->get_logger(), "State %s Walker transition: %s", sourceState->toShortName().c_str(),
189 demangleSymbol(typeid(Ev).name()).c_str());
190 processTransitionAux(t, sourceState, false, transitionTypeInfo);
191}

References demangleSymbol(), globalNh_, and processTransitionAux().

Here is the call graph for this function:

◆ processTransition() [3/4]

template<typename Ev >
void smacc2::introspection::processTransition ( statechart::custom_reaction< Ev > *  ,
std::shared_ptr< SmaccStateInfo > &  sourceState 
)

Definition at line 328 of file smacc_state_machine_info.hpp.

330{
331 // RCLCPP_INFO_STREAM(getLogger(),"GOTCHA");
332}

◆ processTransition() [4/4]

template<typename Ev , typename Dst >
void smacc2::introspection::processTransition ( statechart::transition< Ev, Dst > *  ,
std::shared_ptr< SmaccStateInfo > &  sourceState 
)

Definition at line 321 of file smacc_state_machine_info.hpp.

323{
324 // RCLCPP_INFO_STREAM(getLogger(),"GOTCHA");
325}

◆ processTransitionAux()

template<typename Ev , typename Dst , typename Tag >
void smacc2::introspection::processTransitionAux ( smacc2::Transition< Ev, Dst, Tag > *  ,
std::shared_ptr< SmaccStateInfo > &  sourceState,
bool  history,
TypeInfo::Ptr transitionTypeInfo 
)

Definition at line 194 of file smacc_state_machine_info.hpp.

197{
198 RCLCPP_INFO(
199 globalNh_->get_logger(), "State %s Walker transition: %s", sourceState->toShortName().c_str(),
200 demangleSymbol(typeid(Ev).name()).c_str());
201 std::string transitionTag;
202 std::string transitionType;
203
204 if (typeid(Tag) != typeid(default_transition_name))
205 {
206 transitionTag = demangleSymbol<Tag>();
207 transitionType = getTransitionType<Tag>();
208 RCLCPP_DEBUG_STREAM(globalNh_->get_logger(), "TRANSITION TYPE:" << transitionType);
209 }
210 else
211 {
212 transitionTag = "";
213 automaticTransitionTag<Ev>(transitionTag);
214 automaticTransitionType<Ev>(transitionType);
215 }
216
217 RCLCPP_INFO_STREAM(globalNh_->get_logger(), "Transition tag: " << transitionTag);
218
219 if (!sourceState->stateMachine_->containsState<Dst>())
220 {
221 auto realparentState = sourceState->stateMachine_->getState<typename Dst::TContext>();
222 auto siblingnode = sourceState->stateMachine_->createState<Dst>(realparentState);
223
224 // auto siblingnode = sourceState->stateMachine_->createState<Dst>(sourceState->parentState_);
225 WalkStatesExecutor<Dst>::walkStates(siblingnode, true);
226 sourceState->declareTransition<Ev>(
227 siblingnode, transitionTag, transitionType, history, transitionTypeInfo);
228 }
229 else
230 {
231 // auto realparentState = sourceState->stateMachine_->getState<typename Dst::TContext>();
232 // auto siblingnode = sourceState->stateMachine_->createState<Dst>(realparentState);
233
234 auto siblingnode = sourceState->stateMachine_->getState<Dst>();
235 sourceState->declareTransition<Ev>(
236 siblingnode, transitionTag, transitionType, history, transitionTypeInfo);
237 }
238}

References demangleSymbol(), globalNh_, and smacc2::introspection::WalkStatesExecutor< InitialStateType >::walkStates().

Referenced by processTransition().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processTransitions() [1/2]

template<typename T >
enable_if< boost::mpl::is_sequence< T > >::type smacc2::introspection::processTransitions ( std::shared_ptr< SmaccStateInfo > &  sourceState)

Definition at line 160 of file smacc_state_machine_info.hpp.

162{
163 RCLCPP_INFO(
164 globalNh_->get_logger(), "State %s Walker has transition list",
165 sourceState->fullStateName.c_str());
166 using boost::mpl::_1;
167 using wrappedList = typename boost::mpl::transform<T, add_type_wrapper<_1>>::type;
168 boost::mpl::for_each<wrappedList>(AddTransition(sourceState));
169}

References globalNh_.

◆ processTransitions() [2/2]

template<typename T >
disable_if< boost::mpl::is_sequence< T > >::type smacc2::introspection::processTransitions ( std::shared_ptr< SmaccStateInfo > &  sourceState)

Definition at line 338 of file smacc_state_machine_info.hpp.

340{
341 // RCLCPP_INFO_STREAM(getLogger(),"state transition from: " << sourceState->demangledStateName <<
342 // " of type: " << demangledTypeName<T>());
343 T * dummy = nullptr;
344 processTransition(dummy, sourceState);
345}
void processTransition(smacc2::Transition< Ev, boost::statechart::deep_history< Dst >, Tag > *, std::shared_ptr< SmaccStateInfo > &sourceState)

References processTransition().

Here is the call graph for this function:

◆ replace()

bool smacc2::introspection::replace ( std::string &  str,
const std::string &  from,
const std::string &  to 
)

Definition at line 39 of file string_type_walker.cpp.

40{
41 size_t start_pos = str.find(from);
42 if (start_pos == std::string::npos) return false;
43 str.replace(start_pos, from.length(), to);
44 return true;
45}

Referenced by smacc2::introspection::TypeInfo::getTypeInfoFromString(), and replace_back().

Here is the caller graph for this function:

◆ replace_back()

std::string smacc2::introspection::replace_back ( std::string  roottype,
std::vector< std::pair< std::string, std::string > > &  orderedtypesdict 
)

Definition at line 47 of file string_type_walker.cpp.

49{
50 while (roottype.find("$") != std::string::npos)
51 {
52 for (auto & t : orderedtypesdict)
53 {
54 auto & tkey = t.first;
55 auto & tval = t.second;
56
57 replace(roottype, tkey, tval);
58 }
59 }
60
61 return roottype;
62
63 // def replace_back(roottype, typesdict):
64 // # replace back
65 // while "$" in roottype:
66 // #print roottype
67 // for tkey in typesdict:
68 // tval = typesdict[tkey]
69 // roottype = roottype.replace(tkey, tval)
70
71 // return roottype
72}
bool replace(std::string &str, const std::string &from, const std::string &to)

References replace().

Referenced by smacc2::introspection::TypeInfo::getTypeInfoFromString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ transitionInfoToMsg()

void smacc2::introspection::transitionInfoToMsg ( const SmaccTransitionInfo transition,
smacc2_msgs::msg::SmaccTransition &  transitionMsg 
)

Definition at line 30 of file reflection.cpp.

32{
33 transitionMsg.index = transition.index;
34
35 if (transition.sourceState != nullptr)
36 {
37 transitionMsg.source_state_name = transition.sourceState->demangledStateName;
38 }
39
40 transitionMsg.transition_name = transition.transitionTag;
41 transitionMsg.transition_type = transition.transitionType;
42
43 if (transition.eventInfo != nullptr)
44 {
45 transitionMsg.event.event_type = transition.eventInfo->getEventTypeName();
46 transitionMsg.event.event_source = transition.eventInfo->getEventSourceName();
47 transitionMsg.event.event_object_tag = transition.eventInfo->getOrthogonalName();
48 transitionMsg.event.label = transition.eventInfo->label;
49 }
50
51 transitionMsg.history_node = transition.historyNode;
52
53 if (transition.historyNode)
54 {
55 if (transition.destinyState->parentState_ != nullptr)
56 {
57 transitionMsg.destiny_state_name = transition.destinyState->parentState_->demangledStateName;
58 }
59 else
60 {
61 transitionMsg.destiny_state_name = "";
62 }
63 }
64 else
65 {
66 transitionMsg.destiny_state_name = transition.destinyState->demangledStateName;
67 }
68}
std::shared_ptr< const SmaccStateInfo > destinyState
std::shared_ptr< SmaccEventInfo > eventInfo
std::shared_ptr< const SmaccStateInfo > sourceState

References smacc2::introspection::SmaccTransitionInfo::destinyState, smacc2::introspection::SmaccTransitionInfo::eventInfo, smacc2::introspection::SmaccTransitionInfo::historyNode, smacc2::introspection::SmaccTransitionInfo::index, smacc2::introspection::SmaccTransitionInfo::sourceState, smacc2::introspection::SmaccTransitionInfo::transitionTag, and smacc2::introspection::SmaccTransitionInfo::transitionType.

Referenced by smacc2::introspection::SmaccStateMachineInfo::assembleSMStructureMessage(), and smacc2::ISmaccStateMachine::publishTransition().

Here is the caller graph for this function:

Variable Documentation

◆ globalNh_

rclcpp::Node::SharedPtr smacc2::introspection::globalNh_