33#define THIS_STATE_NAME ((demangleSymbol(typeid(*this).name()).c_str()))
34template <
typename TOrthogonal,
typename TBehavior,
typename... Args>
42 if (orthogonal !=
nullptr)
45 auto clientBehavior = std::make_shared<TBehavior>(args...);
46 orthogonal->addClientBehavior(clientBehavior);
47 clientBehavior->template onStateOrthogonalAllocation<TOrthogonal, TBehavior>();
53 ev->behaviorName = behavior->
getName();
57 return clientBehavior;
62 getLogger(),
"[%s] Skipping client behavior creation in orthogonal [%s]. It does not exist.",
69template <
typename SmaccComponentType>
76template <
typename SmaccComponentType>
84template <
typename SmaccClientType>
89 for (
auto & ortho : orthogonals)
91 ortho.second->requiresClient(storage);
92 if (storage !=
nullptr)
return;
101 "[%s] Client of type '%s' not found in any orthogonal of the current state machine. This may "
102 "produce a segmentation fault if the returned reference is used.",
122template <
typename TStateReactor,
typename... TEvArgs>
125 auto sr = std::make_shared<TStateReactor>(args...);
130template <
typename TEventGenerator,
typename... TEvArgs>
133 auto eg = std::make_shared<TEventGenerator>(args...);
139template <
typename TEventList>
145 template <
typename T>
156template <
typename TEventList>
162 template <
typename T>
169template <
typename TStateReactor,
typename TTriggerEvent,
typename TEventList,
typename... TEvArgs>
172 auto sr = std::make_shared<TStateReactor>(args...);
173 sr->initialize(
this);
174 sr->template setOutputEvent<TTriggerEvent>();
176 using boost::mpl::_1;
177 using wrappedList =
typename boost::mpl::transform<TEventList, _1>::type;
179 boost::mpl::for_each<wrappedList>(op);
185template <
typename TOrthogonal>
191template <
typename TOrthogonal,
typename TClientBehavior>
197template <
typename TEventGenerator>
200 TEventGenerator * ret =
nullptr;
203 ret =
dynamic_cast<TEventGenerator *
>(evg.get());
204 if (ret !=
nullptr)
break;
209template <
typename TStateReactor>
212 TStateReactor * ret =
nullptr;
215 ret =
dynamic_cast<TStateReactor *
>(sr.get());
216 if (ret !=
nullptr)
break;
223template <
typename EventType>
229template <
typename EventType>
236template <
typename TransitionType>
std::string getName() const
void postEvent(const EventType &ev)
std::function< void(const std::string &)> postInitializationFailureEventFn_
void setGlobalSMData(const std::string &name, T value)
TClientBehavior * getClientBehavior(int index=0)
TOrthogonal * getOrthogonal()
const std::map< std::string, std::shared_ptr< smacc2::ISmaccOrthogonal > > & getOrthogonals() const
bool getGlobalSMData(const std::string &name, T &ret)
void requiresComponent(SmaccComponentType *&storage, ComponentRequirement requirementType, ISmaccOrthogonal *first=nullptr)
void postEvent(EventType *ev, EventLifeTime evlifetime=EventLifeTime::ABSOLUTE)
rclcpp::Logger getLogger()
TClientBehavior * getClientBehavior(int index=0)
std::shared_ptr< TEventGenerator > createEventGenerator(TEvArgs... args)
std::vector< std::shared_ptr< StateReactor > > stateReactors_
std::shared_ptr< TBehavior > configure(Args &&... args)
void requiresClient(SmaccClientType *&storage)
void requiresComponent(SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT)
std::shared_ptr< TStateReactor > createStateReactor(TEvArgs... args)
bool getGlobalSMData(const std::string &name, T &ret)
TOrthogonal * getOrthogonal()
TStateReactor * getStateReactor()
virtual ISmaccStateMachine & getStateMachine()=0
std::vector< std::shared_ptr< smacc2::SmaccEventGenerator > > eventGenerators_
TEventGenerator * getEventGenerator()
void setGlobalSMData(const std::string &name, T value)
void notifyTransitionFromTransitionTypeInfo(std::shared_ptr< smacc2::introspection::TypeInfo > &transitionTypeInfo)
static TypeInfo::Ptr getTypeInfoFromType()
std::enable_if< HasEventLabel< T >::value, void >::type EventLabel(std::string &label)
std::string demangleSymbol()
std::string demangledTypeName()
boost::intrusive_ptr< EventType > makeEvent(Args &&... args)
smacc2::SmaccStateReactorInfo * srInfo_
AddTEventTypeStateReactorInfo(smacc2::SmaccStateReactorInfo *srInfo)
smacc2::StateReactor * sr_
AddTEventTypeStateReactor(smacc2::StateReactor *sr)
std::vector< std::shared_ptr< SmaccEventInfo > > sourceEventTypes