33#define THIS_STATE_NAME ((demangleSymbol(typeid(*this).name()).c_str()))
34template <
typename TOrthogonal,
typename TBehavior,
typename... Args>
42 if (orthogonal !=
nullptr)
45 std::shared_ptr<TBehavior>(
new TBehavior(args...));
47 orthogonal->addClientBehavior(clientBehavior);
48 clientBehavior->template onStateOrthogonalAllocation<TOrthogonal, TBehavior>();
49 return clientBehavior;
54 getLogger(),
"[%s] Skipping client behavior creation in orthogonal [%s]. It does not exist.",
61template <
typename SmaccComponentType>
68template <
typename SmaccClientType>
71 const char * sname = (
demangleSymbol(
typeid(*this).name()).c_str());
74 for (
auto & ortho : orthogonals)
76 ortho.second->requiresClient(storage);
77 if (storage !=
nullptr)
return;
82 "[%s] Client of type '%s' not found in any orthogonal of the current state machine. This may "
83 "produce a segmentation fault if the returned reference is used.",
103template <
typename TStateReactor,
typename... TEvArgs>
106 auto sr = std::make_shared<TStateReactor>(args...);
111template <
typename TEventGenerator,
typename... TEvArgs>
114 auto eg = std::make_shared<TEventGenerator>(args...);
120template <
typename TEventList>
126 template <
typename T>
137template <
typename TEventList>
143 template <
typename T>
150template <
typename TStateReactor,
typename TTriggerEvent,
typename TEventList,
typename... TEvArgs>
153 auto sr = std::make_shared<TStateReactor>(args...);
154 sr->initialize(
this);
155 sr->template setOutputEvent<TTriggerEvent>();
157 using boost::mpl::_1;
158 using wrappedList =
typename boost::mpl::transform<TEventList, _1>::type;
160 boost::mpl::for_each<wrappedList>(op);
166template <
typename TOrthogonal>
172template <
typename TOrthogonal,
typename TClientBehavior>
178template <
typename TEventGenerator>
181 TEventGenerator * ret =
nullptr;
184 ret =
dynamic_cast<TEventGenerator *
>(evg.get());
185 if (ret !=
nullptr)
break;
190template <
typename TStateReactor>
193 TStateReactor * ret =
nullptr;
196 ret =
dynamic_cast<TStateReactor *
>(sr.get());
197 if (ret !=
nullptr)
break;
204template <
typename EventType>
210template <
typename EventType>
217template <
typename TransitionType>
bool getGlobalSMData(std::string name, T &ret)
TClientBehavior * getClientBehavior(int index=0)
void requiresComponent(SmaccComponentType *&storage, ComponentRequirement requirementType)
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)
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)
static TypeInfo::Ptr getTypeInfoFromType()
std::enable_if< HasEventLabel< T >::value, void >::type EventLabel(std::string &label)
std::string demangleSymbol()
std::string demangledTypeName()
smacc2::SmaccStateReactorInfo * srInfo_
AddTEventTypeStateReactorInfo(smacc2::SmaccStateReactorInfo *srInfo)
smacc2::StateReactor * sr_
AddTEventTypeStateReactor(smacc2::StateReactor *sr)
std::vector< std::shared_ptr< SmaccEventInfo > > sourceEventTypes