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)
46 auto clientBehavior = std::shared_ptr<TBehavior>(
new TBehavior(
args...));
47 clientBehavior->currentState =
this;
48 orthogonal->addClientBehavior(clientBehavior);
49 clientBehavior->template onOrthogonalAllocation<TOrthogonal, TBehavior>();
50 return clientBehavior;
55 getLogger(),
"[%s] Skipping client behavior creation in orthogonal [%s]. It does not exist.",
62template <
typename SmaccComponentType>
69template <
typename SmaccClientType>
72 const char * sname = (
demangleSymbol(
typeid(*this).name()).c_str());
75 for (
auto & ortho : orthogonals)
77 ortho.second->requiresClient(storage);
78 if (storage !=
nullptr)
return;
83 "[%s] Client of type '%s' not found in any orthogonal of the current state machine. This may "
84 "produce a segmentation fault if the returned reference is used.",
85 sname, demangleSymbol<SmaccClientType>().c_str());
104template <
typename TStateReactor,
typename... TEvArgs>
107 auto sr = std::make_shared<TStateReactor>(
args...);
114template <
typename TEventGenerator,
typename... TEvArgs>
117 auto eg = std::make_shared<TEventGenerator>(
args...);
123template <
typename TEventList>
129 template <
typename T>
132 auto evinfo = std::make_shared<SmaccEventInfo>(TypeInfo::getTypeInfoFromType<T>());
134 EventLabel<T>(evinfo->label);
140template <
typename TEventList>
146 template <
typename T>
153template <
typename TStateReactor,
typename TTriggerEvent,
typename TEventList,
typename... TEvArgs>
156 auto sr = std::make_shared<TStateReactor>(
args...);
157 sr->initialize(
this);
158 sr->template setOutputEvent<TTriggerEvent>();
160 using boost::mpl::_1;
163 boost::mpl::for_each<wrappedList>(op);
169template <
typename TOrthogonal>
175template <
typename TEventGenerator>
178 TEventGenerator * ret =
nullptr;
181 ret =
dynamic_cast<TEventGenerator *
>(evg.get());
182 if (ret !=
nullptr)
break;
187template <
typename TStateReactor>
190 TStateReactor * ret =
nullptr;
193 ret =
dynamic_cast<TStateReactor *
>(sr.get());
194 if (ret !=
nullptr)
break;
211template <
typename EventType>
217template <
typename EventType>
224template <
typename TransitionType>
227 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 requiresComponent(SmaccComponentType *&storage)
void postEvent(EventType *ev, EventLifeTime evlifetime=EventLifeTime::ABSOLUTE)
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(const std::string &name)
smacc2::SmaccStateReactorInfo * srInfo_
AddTEventTypeStateReactorInfo(smacc2::SmaccStateReactorInfo *srInfo)
smacc2::StateReactor * sr_
AddTEventTypeStateReactor(smacc2::StateReactor *sr)
std::vector< std::shared_ptr< SmaccEventInfo > > sourceEventTypes