26 return nh.getParam(param_name, param_storage);
34 return nh.setParam(param_name, param_val);
42 return nh.param(param_name, param_val, default_val);
46#define THIS_STATE_NAME ((demangleSymbol(typeid(*this).name()).c_str()))
47 template <
typename TOrthogonal,
typename TBehavior,
typename... Args>
50 std::string orthogonalkey = demangledTypeName<TOrthogonal>();
51 ROS_INFO(
"[%s] Configuring orthogonal: %s",
THIS_STATE_NAME, orthogonalkey.c_str());
53 TOrthogonal *orthogonal = this->getOrthogonal<TOrthogonal>();
54 if (orthogonal !=
nullptr)
56 auto clientBehavior = std::shared_ptr<TBehavior>(
new TBehavior(args...));
57 clientBehavior->currentState =
this;
58 orthogonal->addClientBehavior(clientBehavior);
59 clientBehavior->template onOrthogonalAllocation<TOrthogonal, TBehavior>();
60 return clientBehavior;
64 ROS_ERROR(
"[%s] Skipping client behavior creation in orthogonal [%s]. It does not exist.",
THIS_STATE_NAME, orthogonalkey.c_str());
70 template <
typename SmaccComponentType>
77 template <
typename SmaccClientType>
80 const char *sname = (
demangleSymbol(
typeid(*this).name()).c_str());
83 for (
auto &ortho : orthogonals)
85 ortho.second->requiresClient(storage);
86 if (storage !=
nullptr)
90 ROS_ERROR(
"[%s] Client of type '%s' not found in any orthogonal of the current state machine. This may produce a segmentation fault if the returned reference is used.", sname, demangleSymbol<SmaccClientType>().c_str());
102 template <
typename T>
109 template <
typename TStateReactor,
typename... TEvArgs>
112 auto sr = std::make_shared<TStateReactor>(args...);
119 template <
typename TEventGenerator,
typename... TEvArgs>
122 auto eg = std::make_shared<TEventGenerator>(args...);
127 template <
typename TEventList>
135 template <
typename T>
142 template <
typename TStateReactor,
typename TTriggerEvent,
typename TEventList,
typename... TEvArgs>
145 auto sr = std::make_shared<TStateReactor>(args...);
147 sr->initialize(
this);
148 sr->template setOutputEvent<TTriggerEvent>();
150 using boost::mpl::_1;
151 using wrappedList =
typename boost::mpl::transform<TEventList, _1>::type;
153 boost::mpl::for_each<wrappedList>(op);
160 template <
typename TOrthogonal>
167 template <
typename TEventGenerator>
170 TEventGenerator* ret =
nullptr;
173 ret =
dynamic_cast<TEventGenerator *
>(evg.get());
180 template <
typename TStateReactor>
183 TStateReactor* ret =
nullptr;
186 ret =
dynamic_cast<TStateReactor *
>(sr.get());
205 template <
typename EventType>
211 template <
typename EventType>
218 template <
typename TransitionType>
221 auto transitionType = TypeInfo::getTypeInfoFromType<TransitionType>();
TOrthogonal * getOrthogonal()
const std::map< std::string, std::shared_ptr< smacc::ISmaccOrthogonal > > & getOrthogonals() const
void setGlobalSMData(std::string name, T value)
void requiresComponent(SmaccComponentType *&storage)
bool getGlobalSMData(std::string name, T &ret)
void postEvent(EventType *ev, EventLifeTime evlifetime=EventLifeTime::ABSOLUTE)
void setParam(std::string param_name, T param_val)
TEventGenerator * getEventGenerator()
void setGlobalSMData(std::string name, T value)
bool param(std::string param_name, T ¶m_val, const T &default_val) const
std::shared_ptr< TStateReactor > createStateReactor(TEvArgs... args)
TStateReactor * getStateReactor()
std::vector< std::shared_ptr< StateReactor > > stateReactors_
void requiresClient(SmaccClientType *&storage)
virtual ISmaccStateMachine & getStateMachine()=0
std::vector< std::shared_ptr< smacc::SmaccEventGenerator > > eventGenerators_
std::shared_ptr< TEventGenerator > createEventGenerator(TEvArgs... args)
bool getParam(std::string param_name, T ¶m_storage)
void notifyTransitionFromTransitionTypeInfo(std::shared_ptr< smacc::introspection::TypeInfo > &transitionTypeInfo)
std::shared_ptr< TBehavior > configure(Args &&... args)
bool getGlobalSMData(std::string name, T &ret)
TOrthogonal * getOrthogonal()
void requiresComponent(SmaccComponentType *&storage)
std::string demangleSymbol()
AddTEventType(smacc::StateReactor *sr)
smacc::StateReactor * sr_