SMACC
Loading...
Searching...
No Matches
Classes | Typedefs | Enumerations | Functions
smacc::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, PREEMPT, CONTINUELOOP, ENDLOOPDEFAULT_TRANSITION_TYPES
 

Enumerations

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

Functions

void transitionInfoToMsg (const SmaccTransitionInfo &transition, smacc_msgs::SmaccTransition &transitionMsg)
 
template<class T >
auto optionalNodeHandle (boost::intrusive_ptr< T > &obj) -> ros::NodeHandle
 
template<class T >
auto optionalNodeHandle (T *) -> ros::NodeHandle
 
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 (smacc::Transition< Ev, boost::statechart::deep_history< Dst >, Tag > *, std::shared_ptr< SmaccStateInfo > &sourceState)
 
template<typename Ev , typename Dst , typename Tag >
void processTransition (smacc::Transition< Ev, Dst, Tag > *t, std::shared_ptr< SmaccStateInfo > &sourceState)
 
template<typename Ev , typename Dst , typename Tag >
void processTransitionAux (smacc::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)
 

Typedef Documentation

◆ DEFAULT_TRANSITION_TYPES

Definition at line 204 of file introspection.h.

◆ SmaccAllocator

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

Definition at line 36 of file introspection.h.

Enumeration Type Documentation

◆ SmaccStateType

Enumerator
SUPERSTATE 
STATE 
SUPERSTATE_ROUTINE 

Definition at line 129 of file smacc_state_info.h.

Function Documentation

◆ automaticTransitionTag() [1/2]

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

Definition at line 157 of file introspection.h.

158{
159 transition_name = T::getDefaultTransitionTag();
160}

◆ automaticTransitionTag() [2/2]

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

Definition at line 164 of file introspection.h.

165{
166 transition_name = "";
167}

◆ automaticTransitionType() [1/2]

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

Definition at line 191 of file introspection.h.

192{
193 transition_type = T::getDefaultTransitionType();
194}

◆ automaticTransitionType() [2/2]

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

Definition at line 198 of file introspection.h.

199{
200 transition_type = demangledTypeName<DEFAULT>();
201}

◆ CallOnDefinition() [1/2]

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

Definition at line 344 of file smacc_state_machine_info.h.

345{
346 /* something when T has toString ... */
347 ROS_INFO_STREAM("EXECUTING ONDEFINITION: " << demangleSymbol(typeid(T).name()));
348 T::staticConfigure();
349}
std::string demangleSymbol(const std::string &name)
Definition: introspection.h:51

References demangleSymbol().

Here is the call graph for this function:

◆ CallOnDefinition() [2/2]

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

Definition at line 353 of file smacc_state_machine_info.h.

354{
355 ROS_INFO_STREAM("static OnDefinition: dont exist for " << demangleSymbol(typeid(T).name()));
356 /* something when T has toString ... */
357}

References demangleSymbol().

Here is the call graph for this function:

◆ demangledTypeName()

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

Definition at line 81 of file introspection.h.

82{
83 return demangleSymbol(typeid(T).name());
84}

References demangleSymbol().

Here is the call graph for this function:

◆ demangleSymbol() [1/3]

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

Definition at line 75 of file introspection.h.

76{
77 return demangleSymbol(typeid(T).name());
78}

References demangleSymbol().

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

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

◆ demangleSymbol() [2/3]

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

Definition at line 56 of file introspection.h.

57{
58#if (__GNUC__ && __cplusplus && __GNUC__ >= 3)
59 int status;
60 char *res = abi::__cxa_demangle(name, 0, 0, &status);
61 if (res)
62 {
63 const std::string demangled_name(res);
64 std::free(res);
65 return demangled_name;
66 }
67 // Demangling failed, fallback to mangled name
68 return std::string(name);
69#else
70 return std::string(name);
71#endif
72}

◆ demangleSymbol() [3/3]

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

Definition at line 51 of file introspection.h.

52{
53 return demangleSymbol(name.c_str());
54}

References demangleSymbol().

Here is the call graph for this function:

◆ demangleType() [1/2]

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

Definition at line 91 of file introspection.h.

92{
93 return demangleSymbol(tinfo.name());
94}

References demangleSymbol().

Here is the call graph for this function:

◆ demangleType() [2/2]

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

◆ EventLabel() [1/2]

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

Definition at line 123 of file introspection.h.

124{
125 label = T::getEventLabel();
126}

◆ EventLabel() [2/2]

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

Definition at line 130 of file introspection.h.

131{
132 label = "";
133}

◆ getTransitionType()

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

Definition at line 243 of file introspection.h.

244{
245 std::string output;
246 CheckType<TTransition> op(&output);
247 using boost::mpl::_1;
248 using wrappedList = typename boost::mpl::transform<DEFAULT_TRANSITION_TYPES, _1>::type;
249
250 boost::mpl::for_each<wrappedList>(op);
251 return output;
252};

◆ optionalNodeHandle() [1/2]

template<class T >
auto smacc::introspection::optionalNodeHandle ( boost::intrusive_ptr< T > &  obj) -> ros::NodeHandle

Definition at line 39 of file introspection.h.

41{
42 return obj->getROSNode();
43}

Referenced by smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::SmaccState().

Here is the caller graph for this function:

◆ optionalNodeHandle() [2/2]

template<class T >
auto smacc::introspection::optionalNodeHandle ( T *  ) -> ros::NodeHandle

Definition at line 46 of file introspection.h.

47{
48 return ros::NodeHandle("");
49}

◆ processSubState() [1/2]

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

◆ processSubState() [2/2]

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

Definition at line 119 of file smacc_state_machine_info.h.

120{
121 using boost::mpl::_1;
122 using wrappedList = typename boost::mpl::transform<T, add_type_wrapper<_1>>::type;
123 boost::mpl::for_each<wrappedList>(AddSubState(parentState));
124}

◆ processTransition() [1/4]

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

Definition at line 140 of file smacc_state_machine_info.h.

141{
142 auto transitionTypeInfo = TypeInfo::getTypeInfoFromType<smacc::Transition<Ev, boost::statechart::deep_history<Dst>, Tag>>();
144 processTransitionAux(mock, sourceState, true, transitionTypeInfo);
145}
void processTransitionAux(smacc::Transition< Ev, Dst, Tag > *, std::shared_ptr< SmaccStateInfo > &sourceState, bool history, TypeInfo::Ptr &transitionTypeInfo)

References 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 smacc::introspection::processTransition ( smacc::Transition< Ev, Dst, Tag > *  t,
std::shared_ptr< SmaccStateInfo > &  sourceState 
)

Definition at line 148 of file smacc_state_machine_info.h.

149{
150 auto transitionTypeInfo = TypeInfo::getTypeInfoFromType<smacc::Transition<Ev, Dst, Tag>>();
151 processTransitionAux(t, sourceState, false, transitionTypeInfo);
152}

References processTransitionAux().

Here is the call graph for this function:

◆ processTransition() [3/4]

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

Definition at line 257 of file smacc_state_machine_info.h.

258{
259 //ROS_INFO_STREAM("GOTCHA");
260}

◆ processTransition() [4/4]

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

Definition at line 251 of file smacc_state_machine_info.h.

252{
253 //ROS_INFO_STREAM("GOTCHA");
254}

◆ processTransitionAux()

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

Definition at line 155 of file smacc_state_machine_info.h.

156{
157 ROS_INFO("State %s Walker transition: %s", sourceState->toShortName().c_str(), demangleSymbol(typeid(Ev).name()).c_str());
158 std::string transitionTag;
159 std::string transitionType;
160
161 if (typeid(Tag) != typeid(default_transition_name))
162 {
163 transitionTag = demangleSymbol<Tag>();
164 transitionType = getTransitionType<Tag>();
165 ROS_DEBUG_STREAM("TRANSITION TYPE:" << transitionType);
166 }
167 else
168 {
169 transitionTag = "";
170 automaticTransitionTag<Ev>(transitionTag);
171 automaticTransitionType<Ev>(transitionType);
172 }
173
174 ROS_INFO_STREAM("Transition tag: " << transitionTag);
175
176 if (!sourceState->stateMachine_->containsState<Dst>())
177 {
178 auto realparentState = sourceState->stateMachine_->getState<typename Dst::TContext>();
179 auto siblingnode = sourceState->stateMachine_->createState<Dst>(realparentState);
180
181 //auto siblingnode = sourceState->stateMachine_->createState<Dst>(sourceState->parentState_);
182 WalkStatesExecutor<Dst>::walkStates(siblingnode, true);
183 sourceState->declareTransition<Ev>(siblingnode, transitionTag, transitionType, history, transitionTypeInfo);
184 }
185 else
186 {
187 //auto realparentState = sourceState->stateMachine_->getState<typename Dst::TContext>();
188 //auto siblingnode = sourceState->stateMachine_->createState<Dst>(realparentState);
189
190 auto siblingnode = sourceState->stateMachine_->getState<Dst>();
191 sourceState->declareTransition<Ev>(siblingnode, transitionTag, transitionType, history, transitionTypeInfo);
192 }
193}

References demangleSymbol(), and smacc::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 smacc::introspection::processTransitions ( std::shared_ptr< SmaccStateInfo > &  sourceState)

Definition at line 130 of file smacc_state_machine_info.h.

131{
132
133 ROS_INFO_STREAM("State %s Walker has transition list");
134 using boost::mpl::_1;
135 using wrappedList = typename boost::mpl::transform<T, add_type_wrapper<_1>>::type;
136 boost::mpl::for_each<wrappedList>(AddTransition(sourceState));
137}

◆ processTransitions() [2/2]

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

Definition at line 267 of file smacc_state_machine_info.h.

268{
269 //ROS_INFO_STREAM("state transition from: " << sourceState->demangledStateName << " of type: " << demangledTypeName<T>());
270 T *dummy;
271 processTransition(dummy, sourceState);
272}
void processTransition(smacc::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 smacc::introspection::replace ( std::string &  str,
const std::string &  from,
const std::string &  to 
)

Definition at line 27 of file string_type_walker.cpp.

28{
29 size_t start_pos = str.find(from);
30 if (start_pos == std::string::npos)
31 return false;
32 str.replace(start_pos, from.length(), to);
33 return true;
34}

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

Here is the caller graph for this function:

◆ replace_back()

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

Definition at line 36 of file string_type_walker.cpp.

37{
38 while (roottype.find("$") != std::string::npos)
39 {
40 for (auto& t : orderedtypesdict)
41 {
42 auto& tkey = t.first;
43 auto& tval = t.second;
44
45 replace(roottype, tkey, tval);
46 }
47 }
48
49 return roottype;
50
51 // def replace_back(roottype, typesdict):
52 // # replace back
53 // while "$" in roottype:
54 // #print roottype
55 // for tkey in typesdict:
56 // tval = typesdict[tkey]
57 // roottype = roottype.replace(tkey, tval)
58
59 // return roottype
60}
bool replace(std::string &str, const std::string &from, const std::string &to)

References replace().

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

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

◆ transitionInfoToMsg()

void smacc::introspection::transitionInfoToMsg ( const SmaccTransitionInfo transition,
smacc_msgs::SmaccTransition &  transitionMsg 
)

Definition at line 9 of file reflection.cpp.

10{
11 transitionMsg.index = transition.index;
12 transitionMsg.event.event_type = transition.eventInfo->getEventTypeName();
13
14 transitionMsg.source_state_name = transition.sourceState->demangledStateName;
15
16 transitionMsg.transition_name = transition.transitionTag;
17 transitionMsg.transition_type = transition.transitionType;
18 transitionMsg.event.event_source = transition.eventInfo->getEventSourceName();
19 transitionMsg.event.event_object_tag = transition.eventInfo->getOrthogonalName();
20 transitionMsg.event.label = transition.eventInfo->label;
21 transitionMsg.history_node = transition.historyNode;
22
23 if (transition.historyNode)
24 {
25 if (transition.destinyState->parentState_ != nullptr)
26 transitionMsg.destiny_state_name = transition.destinyState->parentState_->demangledStateName;
27 else
28 transitionMsg.destiny_state_name = "";
29 }
30 else
31 {
32 transitionMsg.destiny_state_name = transition.destinyState->demangledStateName;
33 }
34}
std::shared_ptr< SmaccStateInfo > destinyState
std::shared_ptr< SmaccEventInfo > eventInfo
std::shared_ptr< SmaccStateInfo > sourceState

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

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

Here is the caller graph for this function: