35#define THIS_STATE_NAME ((demangleSymbol(typeid(*this).name()).c_str()))
36template <
typename TOrthogonal,
typename TBehavior,
typename... Args>
39 std::string orthogonalkey = demangledTypeName<TOrthogonal>();
43 TOrthogonal * orthogonal = this->getOrthogonal<TOrthogonal>();
44 if (orthogonal !=
nullptr)
47 std::shared_ptr<TBehavior>(
new TBehavior(args...));
49 orthogonal->addClientBehavior(clientBehavior);
50 clientBehavior->template onOrthogonalAllocation<TOrthogonal, TBehavior>();
51 return clientBehavior;
56 getLogger(),
"[%s] Skipping client behavior creation in orthogonal [%s]. It does not exist.",
63template <
typename SmaccComponentType>
70template <
typename SmaccClientType>
73 const char * sname = (
demangleSymbol(
typeid(*this).name()).c_str());
76 for (
auto & ortho : orthogonals)
78 ortho.second->requiresClient(storage);
79 if (storage !=
nullptr)
return;
84 "[%s] Client of type '%s' not found in any orthogonal of the current state machine. This may "
85 "produce a segmentation fault if the returned reference is used.",
86 sname, demangleSymbol<SmaccClientType>().c_str());
105template <
typename TStateReactor,
typename... TEvArgs>
108 auto sr = std::make_shared<TStateReactor>(args...);
115template <
typename TEventGenerator,
typename... TEvArgs>
118 auto eg = std::make_shared<TEventGenerator>(args...);
124template <
typename TEventList>
130 template <
typename T>
133 auto evinfo = std::make_shared<SmaccEventInfo>(TypeInfo::getTypeInfoFromType<T>());
135 EventLabel<T>(evinfo->label);
141template <
typename TEventList>
147 template <
typename T>
154template <
typename TStateReactor,
typename TTriggerEvent,
typename TEventList,
typename... TEvArgs>
157 auto sr = std::make_shared<TStateReactor>(args...);
158 sr->initialize(
this);
159 sr->template setOutputEvent<TTriggerEvent>();
161 using boost::mpl::_1;
162 using wrappedList =
typename boost::mpl::transform<TEventList, _1>::type;
164 boost::mpl::for_each<wrappedList>(op);
170template <
typename TOrthogonal>
176template <
typename TOrthogonal,
typename TClientBehavior>
182template <
typename TEventGenerator>
185 TEventGenerator * ret =
nullptr;
188 ret =
dynamic_cast<TEventGenerator *
>(evg.get());
189 if (ret !=
nullptr)
break;
194template <
typename TStateReactor>
197 TStateReactor * ret =
nullptr;
200 ret =
dynamic_cast<TStateReactor *
>(sr.get());
201 if (ret !=
nullptr)
break;
218template <
typename EventType>
224template <
typename EventType>
231template <
typename TransitionType>
234 auto transitionType = TypeInfo::getTypeInfoFromType<TransitionType>();
bool getGlobalSMData(std::string name, T &ret)
TClientBehavior * getClientBehavior(int index=0)
void setGlobalSMData(std::string name, T value)
TOrthogonal * getOrthogonal()
const std::map< std::string, std::shared_ptr< smacc2::ISmaccOrthogonal > > & getOrthogonals() const
void requiresComponent(SmaccComponentType *&storage, bool throwsExceptionIfNotExist=false)
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_
bool getGlobalSMData(std::string name, T &ret)
std::shared_ptr< TBehavior > configure(Args &&... args)
void requiresClient(SmaccClientType *&storage)
std::shared_ptr< TStateReactor > createStateReactor(TEvArgs... args)
TOrthogonal * getOrthogonal()
void requiresComponent(SmaccComponentType *&storage)
TStateReactor * getStateReactor()
virtual ISmaccStateMachine & getStateMachine()=0
std::vector< std::shared_ptr< smacc2::SmaccEventGenerator > > eventGenerators_
void setGlobalSMData(std::string name, T value)
TEventGenerator * getEventGenerator()
void notifyTransitionFromTransitionTypeInfo(std::shared_ptr< smacc2::introspection::TypeInfo > &transitionTypeInfo)
std::string demangleSymbol()
smacc2::SmaccStateReactorInfo * srInfo_
AddTEventTypeStateReactorInfo(smacc2::SmaccStateReactorInfo *srInfo)
smacc2::StateReactor * sr_
AddTEventTypeStateReactor(smacc2::StateReactor *sr)
std::vector< std::shared_ptr< SmaccEventInfo > > sourceEventTypes