37#define THIS_STATE_NAME ((demangleSymbol(typeid(*this).name()).c_str()))
38template <
typename TOrthogonal,
typename TBehavior,
typename... Args>
41 std::string orthogonalkey = demangledTypeName<TOrthogonal>();
45 TOrthogonal * orthogonal = this->getOrthogonal<TOrthogonal>();
46 if (orthogonal !=
nullptr)
48 auto clientBehavior = std::shared_ptr<TBehavior>(
new TBehavior(args...));
49 clientBehavior->currentState =
this;
50 orthogonal->addClientBehavior(clientBehavior);
51 clientBehavior->template onOrthogonalAllocation<TOrthogonal, TBehavior>();
52 return clientBehavior;
57 getLogger(),
"[%s] Skipping client behavior creation in orthogonal [%s]. It does not exist.",
64template <
typename SmaccComponentType>
71template <
typename SmaccClientType>
74 const char * sname = (
demangleSymbol(
typeid(*this).name()).c_str());
77 for (
auto & ortho : orthogonals)
79 ortho.second->requiresClient(storage);
80 if (storage !=
nullptr)
return;
85 "[%s] Client of type '%s' not found in any orthogonal of the current state machine. This may "
86 "produce a segmentation fault if the returned reference is used.",
87 sname, demangleSymbol<SmaccClientType>().c_str());
106template <
typename TStateReactor,
typename... TEvArgs>
109 auto sr = std::make_shared<TStateReactor>(args...);
116template <
typename TEventGenerator,
typename... TEvArgs>
119 auto eg = std::make_shared<TEventGenerator>(args...);
125template <
typename TEventList>
131 template <
typename T>
134 auto evinfo = std::make_shared<SmaccEventInfo>(TypeInfo::getTypeInfoFromType<T>());
136 EventLabel<T>(evinfo->label);
142template <
typename TEventList>
148 template <
typename T>
155template <
typename TStateReactor,
typename TTriggerEvent,
typename TEventList,
typename... TEvArgs>
158 auto sr = std::make_shared<TStateReactor>(args...);
159 sr->initialize(
this);
160 sr->template setOutputEvent<TTriggerEvent>();
162 using boost::mpl::_1;
163 using wrappedList =
typename boost::mpl::transform<TEventList, _1>::type;
165 boost::mpl::for_each<wrappedList>(op);
171template <
typename TOrthogonal>
177template <
typename TEventGenerator>
180 TEventGenerator * ret =
nullptr;
183 ret =
dynamic_cast<TEventGenerator *
>(evg.get());
184 if (ret !=
nullptr)
break;
189template <
typename TStateReactor>
192 TStateReactor * ret =
nullptr;
195 ret =
dynamic_cast<TStateReactor *
>(sr.get());
196 if (ret !=
nullptr)
break;
213template <
typename EventType>
219template <
typename EventType>
226template <
typename TransitionType>
229 auto transitionType = TypeInfo::getTypeInfoFromType<TransitionType>();
bool getGlobalSMData(std::string name, T &ret)
void setGlobalSMData(std::string name, T value)
TOrthogonal * getOrthogonal()
const std::map< std::string, std::shared_ptr< smacc2::ISmaccOrthogonal > > & getOrthogonals() const
void postEvent(EventType *ev, EventLifeTime evlifetime=EventLifeTime::ABSOLUTE)
void requiresComponent(SmaccComponentType *&storage, bool throwsException=false)
rclcpp::Logger getLogger()
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