SMACC2
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Types | Private Member Functions | Static Private Member Functions | List of all members
smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode > Class Template Reference

#include <smacc_state_base.hpp>

Inheritance diagram for smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >:
Inheritance graph
Collaboration diagram for smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >:
Collaboration graph

Classes

struct  my_context
 

Public Types

typedef Context TContext
 
typedef Context::inner_context_type context_type
 
typedef context_type::state_iterator state_iterator
 
typedef InnerInitial LastDeepState
 
typedef base_type::outermost_context_base_type outermost_context_base_type
 
typedef base_type::inner_context_ptr_type inner_context_ptr_type
 
typedef base_type::context_ptr_type context_ptr_type
 
typedef base_type::inner_initial_list inner_initial_list
 

Public Member Functions

 SmaccState ()=delete
 
 SmaccState (my_context ctx)
 
virtual ~SmaccState ()
 
const smacc2::introspection::SmaccStateInfogetStateInfo ()
 
std::string getName () override
 
std::string getFullName ()
 
std::string getShortName ()
 
virtual ISmaccStategetParentState ()
 
void exit ()
 
void runtimeConfigure ()
 
void onEntry ()
 
void onExit ()
 
template<typename T >
bool getGlobalSMData (std::string name, T &ret)
 
template<typename T >
void setGlobalSMData (std::string name, T value)
 
template<typename SmaccComponentType >
void requiresComponent (SmaccComponentType *&storage)
 
virtual ISmaccStateMachinegetStateMachine ()
 
void checkWhileLoopConditionAndThrowEvent (bool(MostDerived::*conditionFn)())
 
void throwSequenceFinishedEvent ()
 
- Public Member Functions inherited from smacc2::ISmaccState
ISmaccStategetParentState ()
 
rclcpp::Node::SharedPtr & getNode ()
 
rclcpp::Logger getLogger ()
 
virtual std::string getClassName ()
 
template<typename TOrthogonal , typename TBehavior , typename... Args>
std::shared_ptr< TBehaviorconfigure (Args &&... args)
 
template<typename SmaccComponentType >
void requiresComponent (SmaccComponentType *&storage)
 
template<typename SmaccClientType >
void requiresClient (SmaccClientType *&storage)
 
template<typename T >
bool getGlobalSMData (std::string name, T &ret)
 
template<typename T >
void setGlobalSMData (std::string name, T value)
 
template<typename TStateReactor , typename TTriggerEvent , typename TEventList , typename... TEvArgs>
std::shared_ptr< TStateReactorcreateStateReactor (TEvArgs... args)
 
template<typename TStateReactor , typename... TEvArgs>
std::shared_ptr< TStateReactorcreateStateReactor (TEvArgs... args)
 
template<typename TEventGenerator , typename... TEvArgs>
std::shared_ptr< TEventGeneratorcreateEventGenerator (TEvArgs... args)
 
template<typename EventType >
void postEvent (const EventType &ev)
 
template<typename EventType >
void postEvent ()
 
template<typename TransitionType >
void notifyTransition ()
 
void notifyTransitionFromTransitionTypeInfo (std::shared_ptr< smacc2::introspection::TypeInfo > &transitionTypeInfo)
 
std::vector< std::shared_ptr< StateReactor > > & getStateReactors ()
 
std::vector< std::shared_ptr< SmaccEventGenerator > > & getEventGenerators ()
 
template<typename TOrthogonal >
TOrthogonalgetOrthogonal ()
 
template<typename TOrthogonal , typename TClientBehavior >
TClientBehaviorgetClientBehavior (int index=0)
 
template<typename TEventGenerator >
TEventGeneratorgetEventGenerator ()
 
template<typename TStateReactor >
TStateReactorgetStateReactor ()
 

Static Public Member Functions

template<typename TOrthogonal , typename TBehavior >
static void configure_orthogonal_runtime (std::function< void(TBehavior &bh, MostDerived &)> initializationFunction)
 
template<typename TOrthogonal , typename TBehavior >
static void configure_orthogonal_runtime (std::function< void(TBehavior &bh)> initializationFunction)
 
template<typename TOrthogonal , typename TBehavior , typename... Args>
static void configure_orthogonal (Args &&... args)
 
template<typename TStateReactor , typename TOutputEvent , typename TInputEventList , typename... TArgs>
static std::shared_ptr< smacc2::introspection::StateReactorHandlerstatic_createStateReactor (TArgs... args)
 
template<typename TEventGenerator , typename... TUArgs>
static std::shared_ptr< smacc2::introspection::EventGeneratorHandlerstatic_createEventGenerator (TUArgs... args)
 
template<typename TStateReactor , typename... TUArgs>
static std::shared_ptr< smacc2::introspection::StateReactorHandlerstatic_createStateReactor_aux (TUArgs... args)
 
static void initial_deep_construct (outermost_context_base_type &outermostContextBase)
 
static void deep_construct (const context_ptr_type &pContext, outermost_context_base_type &outermostContextBase)
 
static inner_context_ptr_type shallow_construct (const context_ptr_type &pContext, outermost_context_base_type &outermostContextBase)
 

Public Attributes

bool finishStateThrown
 
InnerInitialsmacc_inner_type
 

Private Types

typedef sc::simple_state< MostDerived, Context, InnerInitial, historyModebase_type
 

Private Member Functions

void entryStateInternal ()
 

Static Private Member Functions

template<typename TOrthogonal , typename TBehavior >
static void configure_orthogonal_internal (std::function< void(ISmaccState *state)> initializationFunction)
 

Additional Inherited Members

- Protected Attributes inherited from smacc2::ISmaccState
rclcpp::Node::SharedPtr node_
 
std::shared_ptr< rclcpp::Logger > logger_
 
std::vector< std::shared_ptr< StateReactor > > stateReactors_
 
std::vector< std::shared_ptr< smacc2::SmaccEventGenerator > > eventGenerators_
 
ISmaccStateparentState_
 
const smacc2::introspection::SmaccStateInfostateInfo_
 

Detailed Description

template<class MostDerived, class Context, class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
class smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >

Definition at line 39 of file smacc_state_base.hpp.

Member Typedef Documentation

◆ base_type

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
typedef sc::simple_state<MostDerived, Context, InnerInitial, historyMode> smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::base_type
private

Definition at line 42 of file smacc_state_base.hpp.

◆ context_ptr_type

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
typedef base_type::context_ptr_type smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::context_ptr_type

Definition at line 357 of file smacc_state_base.hpp.

◆ context_type

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
typedef Context::inner_context_type smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::context_type

Definition at line 46 of file smacc_state_base.hpp.

◆ inner_context_ptr_type

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
typedef base_type::inner_context_ptr_type smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::inner_context_ptr_type

Definition at line 356 of file smacc_state_base.hpp.

◆ inner_initial_list

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
typedef base_type::inner_initial_list smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::inner_initial_list

Definition at line 358 of file smacc_state_base.hpp.

◆ LastDeepState

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
typedef InnerInitial smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::LastDeepState

Definition at line 49 of file smacc_state_base.hpp.

◆ outermost_context_base_type

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
typedef base_type::outermost_context_base_type smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::outermost_context_base_type

Definition at line 355 of file smacc_state_base.hpp.

◆ state_iterator

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
typedef context_type::state_iterator smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::state_iterator

Definition at line 47 of file smacc_state_base.hpp.

◆ TContext

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
typedef Context smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::TContext

Definition at line 45 of file smacc_state_base.hpp.

Constructor & Destructor Documentation

◆ SmaccState() [1/2]

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::SmaccState ( )
delete

◆ SmaccState() [2/2]

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::SmaccState ( my_context  ctx)
inline

Definition at line 65 of file smacc_state_base.hpp.

66 {
67 static_assert(
68 std::is_base_of<ISmaccState, Context>::value ||
69 std::is_base_of<ISmaccStateMachine, Context>::value,
70 "The context class must be a SmaccState or a SmaccStateMachine");
71 static_assert(
72 !std::is_same<MostDerived, Context>::value,
73 "The context must be a different state or state machine "
74 "than the current state");
75
76 logger_.reset(new rclcpp::Logger(
77 rclcpp::get_logger(smacc2::utils::cleanShortTypeName(typeid(MostDerived)))));
78
79 RCLCPP_INFO(getLogger(), "[%s] creating state ", STATE_NAME);
80 this->set_context(ctx.pContext_);
81
82 node_ = this->getStateMachine().getNode();
83
84 this->stateInfo_ = getStateInfo();
85
86 // storing a reference to the parent state
87 auto & ps = this->template context<Context>();
88 parentState_ = dynamic_cast<ISmaccState *>(&ps);
89 finishStateThrown = false;
90 }
std::shared_ptr< rclcpp::Logger > logger_
rclcpp::Logger getLogger()
rclcpp::Node::SharedPtr node_
ISmaccState * parentState_
const smacc2::introspection::SmaccStateInfo * stateInfo_
virtual ISmaccStateMachine & getStateMachine()
const smacc2::introspection::SmaccStateInfo * getStateInfo()
std::string cleanShortTypeName()
Definition common.hpp:62
#define STATE_NAME

References smacc2::utils::cleanShortTypeName(), smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::finishStateThrown, smacc2::ISmaccState::getLogger(), smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::getStateInfo(), smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::getStateMachine(), smacc2::ISmaccState::logger_, smacc2::ISmaccState::node_, smacc2::ISmaccState::parentState_, STATE_NAME, and smacc2::ISmaccState::stateInfo_.

Here is the call graph for this function:

◆ ~SmaccState()

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
virtual smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::~SmaccState ( )
inlinevirtual

Definition at line 92 of file smacc_state_base.hpp.

92{}

Member Function Documentation

◆ checkWhileLoopConditionAndThrowEvent()

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
void smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::checkWhileLoopConditionAndThrowEvent ( bool(MostDerived::*)()  conditionFn)
inline

Definition at line 330 of file smacc_state_base.hpp.

331 {
332 auto * thisobject = static_cast<MostDerived *>(this);
333 auto condition = boost::bind(conditionFn, thisobject);
334 bool conditionResult = condition();
335
336 // RCLCPP_INFO("LOOP EVENT CONDITION: %d", conditionResult);
337 if (conditionResult)
338 {
339 this->postEvent<EvLoopContinue<MostDerived>>();
340 }
341 else
342 {
343 this->postEvent<EvLoopEnd<MostDerived>>();
344 }
345 RCLCPP_INFO(getLogger(), "[%s] POST THROW CONDITION", STATE_NAME);
346 }

References smacc2::ISmaccState::getLogger(), and STATE_NAME.

Here is the call graph for this function:

◆ configure_orthogonal()

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
template<typename TOrthogonal , typename TBehavior , typename... Args>
static void smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::configure_orthogonal ( Args &&...  args)
inlinestatic

Definition at line 205 of file smacc_state_base.hpp.

206 {
207 configure_orthogonal_internal<TOrthogonal, TBehavior>(
208 [=](ISmaccState * state)
209 {
210 // auto bh = std::make_shared<TBehavior>(args...);
211 state->configure<TOrthogonal, TBehavior>(args...);
212 });
213 }

◆ configure_orthogonal_internal()

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
static void smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::configure_orthogonal_internal ( std::function< void(ISmaccState< MostDerived, Context, InnerInitial, historyMode > *state)>  initializationFunction)
inlinestaticprivate

Definition at line 392 of file smacc_state_base.hpp.

394 {
395 ClientBehaviorInfoEntry bhinfo;
396 bhinfo.factoryFunction = initializationFunction;
397
398 bhinfo.behaviorType = &(typeid(TBehavior));
399 bhinfo.orthogonalType = &(typeid(TOrthogonal));
400
401 const std::type_info * tindex = &(typeid(MostDerived));
402 if (!SmaccStateInfo::staticBehaviorInfo.count(tindex))
403 SmaccStateInfo::staticBehaviorInfo[tindex] = std::vector<ClientBehaviorInfoEntry>();
404
405 SmaccStateInfo::staticBehaviorInfo[tindex].push_back(bhinfo);
406 RCLCPP_INFO_STREAM(
407 rclcpp::get_logger("static"), "[states walking] State "
409 << "client behavior count: "
410 << SmaccStateInfo::staticBehaviorInfo[tindex].size());
411 }
static std::map< const std::type_info *, std::vector< ClientBehaviorInfoEntry > > staticBehaviorInfo

References smacc2::utils::cleanShortTypeName(), and smacc2::introspection::SmaccStateInfo::staticBehaviorInfo.

Here is the call graph for this function:

◆ configure_orthogonal_runtime() [1/2]

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
static void smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::configure_orthogonal_runtime ( std::function< void(TBehavior &bh)>  initializationFunction)
inlinestatic

Definition at line 192 of file smacc_state_base.hpp.

194 {
195 configure_orthogonal_internal<TOrthogonal, TBehavior>(
196 [=](ISmaccState * state)
197 {
198 // auto bh = std::make_shared<TBehavior>(args...);
199 auto bh = state->configure<TOrthogonal, TBehavior>();
200 initializationFunction(*bh);
201 });
202 }

◆ configure_orthogonal_runtime() [2/2]

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
static void smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::configure_orthogonal_runtime ( std::function< void(TBehavior &bh, MostDerived &)>  initializationFunction)
inlinestatic

Definition at line 179 of file smacc_state_base.hpp.

181 {
182 configure_orthogonal_internal<TOrthogonal, TBehavior>(
183 [=](ISmaccState * state)
184 {
185 // auto bh = std::make_shared<TBehavior>(args...);
186 auto bh = state->configure<TOrthogonal, TBehavior>();
187 initializationFunction(*bh, *(static_cast<MostDerived *>(state)));
188 });
189 }

◆ deep_construct()

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
static void smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::deep_construct ( const context_ptr_type pContext,
outermost_context_base_type outermostContextBase 
)
inlinestatic

Definition at line 366 of file smacc_state_base.hpp.

368 {
369 const inner_context_ptr_type pInnerContext(shallow_construct(pContext, outermostContextBase));
370 base_type::template deep_construct_inner<inner_initial_list>(
371 pInnerContext, outermostContextBase);
372 }
static inner_context_ptr_type shallow_construct(const context_ptr_type &pContext, outermost_context_base_type &outermostContextBase)
base_type::inner_context_ptr_type inner_context_ptr_type

References smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::shallow_construct().

Referenced by smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::initial_deep_construct().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ entryStateInternal()

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
void smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::entryStateInternal ( )
inlineprivate

Definition at line 413 of file smacc_state_base.hpp.

414 {
415 // finally we go to the derived state onEntry Function
416
417 RCLCPP_DEBUG(getLogger(), "[%s] State object created. Initializating...", STATE_NAME);
418 this->getStateMachine().notifyOnStateEntryStart(static_cast<MostDerived *>(this));
419
420 RCLCPP_DEBUG_STREAM(
421 getLogger(), "[" << smacc2::utils::cleanShortTypeName(typeid(MostDerived)).c_str()
422 << "] creating ros subnode");
423
424 // before dynamic runtimeConfigure, we execute the staticConfigure behavior configurations
425 {
426 RCLCPP_DEBUG(getLogger(), "[%s] -- STATIC STATE DESCRIPTION --", STATE_NAME);
427
428 for (const auto & clientBehavior : SmaccStateInfo::staticBehaviorInfo)
429 {
430 RCLCPP_DEBUG(
431 getLogger(), "[%s] client behavior info: %s", STATE_NAME,
432 demangleSymbol(clientBehavior.first->name()).c_str());
433 for (auto & cbinfo : clientBehavior.second)
434 {
435 RCLCPP_DEBUG(
436 getLogger(), "[%s] client behavior: %s", STATE_NAME,
437 demangleSymbol(cbinfo.behaviorType->name()).c_str());
438 }
439 }
440
441 const std::type_info * tindex = &(typeid(MostDerived));
442 auto & staticDefinedBehaviors = SmaccStateInfo::staticBehaviorInfo[tindex];
443 auto & staticDefinedStateReactors = SmaccStateInfo::stateReactorsInfo[tindex];
444 auto & staticDefinedEventGenerators = SmaccStateInfo::eventGeneratorsInfo[tindex];
445
446 for (auto & ortho : this->getStateMachine().getOrthogonals())
447 {
448 RCLCPP_INFO(
449 getLogger(), "[%s] Initializing orthogonal: %s", STATE_NAME,
450 demangleSymbol(typeid(*ortho.second).name()).c_str());
451 ortho.second->initState(this);
452 }
453
454 RCLCPP_DEBUG_STREAM(
455 getLogger(), "finding static client behaviors. State Database: "
456 << SmaccStateInfo::staticBehaviorInfo.size() << ". Current state "
457 << cleanShortTypeName(*tindex)
458 << " cbs: " << SmaccStateInfo::staticBehaviorInfo[tindex].size());
459 for (auto & bhinfo : staticDefinedBehaviors)
460 {
461 RCLCPP_DEBUG(
462 getLogger(), "[%s] Creating static client behavior: %s", STATE_NAME,
463 demangleSymbol(bhinfo.behaviorType->name()).c_str());
464 bhinfo.factoryFunction(this);
465 }
466
467 for (auto & sr : staticDefinedStateReactors)
468 {
469 RCLCPP_DEBUG(
470 getLogger(), "[%s] Creating static state reactor: %s", STATE_NAME,
471 sr->stateReactorType->getFullName().c_str());
472 sr->factoryFunction(this);
473 }
474
475 for (auto & eg : staticDefinedEventGenerators)
476 {
477 RCLCPP_DEBUG(
478 getLogger(), "[%s] Creating static event generator: %s", STATE_NAME,
479 eg->eventGeneratorType->getFullName().c_str());
480 eg->factoryFunction(this);
481 }
482
483 RCLCPP_DEBUG(getLogger(), "[%s] ---- END STATIC DESCRIPTION", STATE_NAME);
484 }
485
486 RCLCPP_DEBUG(getLogger(), "[%s] State runtime configuration", STATE_NAME);
487
488 auto * derivedthis = static_cast<MostDerived *>(this);
489
490 // second the orthogonals are internally configured
491 this->getStateMachine().notifyOnRuntimeConfigured(derivedthis);
492
494 // first we runtime configure the state, where we create client behaviors
495 static_cast<MostDerived *>(this)->runtimeConfigure();
497
498 this->getStateMachine().notifyOnRuntimeConfigurationFinished(derivedthis);
499
500 RCLCPP_DEBUG(getLogger(), "[%s] State OnEntry", STATE_NAME);
501
502 static_cast<MostDerived *>(this)->onEntry();
503
504 // here orthogonals and client behaviors are entered OnEntry
505 this->getStateMachine().notifyOnStateEntryEnd(derivedthis);
506 }
static std::map< const std::type_info *, std::vector< std::shared_ptr< SmaccStateReactorInfo > > > stateReactorsInfo
static std::map< const std::type_info *, std::vector< std::shared_ptr< SmaccEventGeneratorInfo > > > eventGeneratorsInfo
std::string demangleSymbol()
void TRACEPOINT(spinOnce)
smacc2_state_onRuntimeConfigure_start
smacc2_state_onRuntimeConfigure_end

References smacc2::utils::cleanShortTypeName(), smacc2::introspection::demangleSymbol(), smacc2::introspection::SmaccStateInfo::eventGeneratorsInfo, smacc2::ISmaccState::getLogger(), smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::getStateMachine(), smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::onEntry(), smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::runtimeConfigure(), smacc2_state_onRuntimeConfigure_end, smacc2_state_onRuntimeConfigure_start, STATE_NAME, smacc2::introspection::SmaccStateInfo::stateReactorsInfo, smacc2::introspection::SmaccStateInfo::staticBehaviorInfo, and TRACEPOINT().

Here is the call graph for this function:

◆ exit()

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
void smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::exit ( )
inline

Definition at line 123 of file smacc_state_base.hpp.

124 {
125 auto * derivedThis = static_cast<MostDerived *>(this);
126 // this->getStateMachine().notifyOnStateExitting(derivedThis);
127 {
128 std::lock_guard<std::recursive_mutex> lock(this->getStateMachine().getMutex());
129 this->getStateMachine().notifyOnStateExitting(derivedThis);
130 try
131 {
133 // static_cast<MostDerived *>(this)->onExit();
134 standardOnExit(*derivedThis);
136 }
137 catch (...)
138 {
139 }
140 this->getStateMachine().notifyOnStateExited(derivedThis);
141 }
142 }
void standardOnExit(TState &st, std::true_type)
smacc2_state_onExit_end
smacc2_state_onExit_start

References smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::getStateMachine(), smacc2_state_onExit_end, smacc2_state_onExit_start, smacc2::standardOnExit(), STATE_NAME, and TRACEPOINT().

Here is the call graph for this function:

◆ getFullName()

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
std::string smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::getFullName ( )
inline

Definition at line 111 of file smacc_state_base.hpp.

111{ return demangleSymbol(typeid(MostDerived).name()); }

References smacc2::introspection::demangleSymbol().

Here is the call graph for this function:

◆ getGlobalSMData()

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
template<typename T >
bool smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::getGlobalSMData ( std::string  name,
T ret 
)
inline

Definition at line 158 of file smacc_state_base.hpp.

159 {
160 return base_type::outermost_context().getGlobalSMData(name, ret);
161 }

◆ getName()

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
std::string smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::getName ( )
inlineoverridevirtual

Implements smacc2::ISmaccState.

Definition at line 109 of file smacc_state_base.hpp.

109{ return getShortName(); }

References smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::getShortName().

Here is the call graph for this function:

◆ getParentState()

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
virtual ISmaccState * smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::getParentState ( )
inlinevirtual

Definition at line 115 of file smacc_state_base.hpp.

116 {
117 // auto* ctx = dynamic_cast<ISmaccState*>(this->template context<Context *>());
118
119 return parentState_;
120 }

References smacc2::ISmaccState::parentState_.

◆ getShortName()

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
std::string smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::getShortName ( )
inline

Definition at line 113 of file smacc_state_base.hpp.

113{ return smacc2::utils::cleanShortTypeName(typeid(MostDerived)); }

References smacc2::utils::cleanShortTypeName().

Referenced by smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::getName().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getStateInfo()

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
const smacc2::introspection::SmaccStateInfo * smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::getStateInfo ( )
inline

Definition at line 94 of file smacc_state_base.hpp.

95 {
96 auto smInfo = this->getStateMachine().getStateMachineInfo();
97
98 auto key = typeid(MostDerived).name();
99 if (smInfo.states.count(key))
100 {
101 return smInfo.states[key].get();
102 }
103 else
104 {
105 return nullptr;
106 }
107 }

References smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::getStateMachine().

Referenced by smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::SmaccState().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getStateMachine()

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
virtual ISmaccStateMachine & smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::getStateMachine ( )
inlinevirtual

◆ initial_deep_construct()

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
static void smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::initial_deep_construct ( outermost_context_base_type outermostContextBase)
inlinestatic

Definition at line 360 of file smacc_state_base.hpp.

361 {
362 deep_construct(&outermostContextBase, outermostContextBase);
363 }
static void deep_construct(const context_ptr_type &pContext, outermost_context_base_type &outermostContextBase)

References smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::deep_construct().

Here is the call graph for this function:

◆ onEntry()

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
void smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::onEntry ( )
inline

Definition at line 151 of file smacc_state_base.hpp.

151{}

Referenced by smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::entryStateInternal().

Here is the caller graph for this function:

◆ onExit()

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
void smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::onExit ( )
inline

Definition at line 155 of file smacc_state_base.hpp.

155{}

◆ requiresComponent()

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
void smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::requiresComponent ( SmaccComponentType *&  storage)
inline

Definition at line 171 of file smacc_state_base.hpp.

172 {
173 base_type::outermost_context().requiresComponent(storage);
174 }

◆ runtimeConfigure()

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
void smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::runtimeConfigure ( )
inline

Definition at line 147 of file smacc_state_base.hpp.

147{}

Referenced by smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::entryStateInternal().

Here is the caller graph for this function:

◆ setGlobalSMData()

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
template<typename T >
void smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::setGlobalSMData ( std::string  name,
T  value 
)
inline

Definition at line 165 of file smacc_state_base.hpp.

166 {
167 base_type::outermost_context().setGlobalSMData(name, value);
168 }

◆ shallow_construct()

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
static inner_context_ptr_type smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::shallow_construct ( const context_ptr_type pContext,
outermost_context_base_type outermostContextBase 
)
inlinestatic

Definition at line 374 of file smacc_state_base.hpp.

376 {
377 // allocating in memory
378 auto state = new MostDerived(
379 SmaccState<MostDerived, Context, InnerInitial, historyMode>::my_context(pContext));
380 const inner_context_ptr_type pInnerContext(state);
381
383 state->entryStateInternal();
385
386 outermostContextBase.add(pInnerContext);
387 return pInnerContext;
388 }
smacc2_state_onEntry_end
smacc2_state_onEntry_start

References smacc2_state_onEntry_end, smacc2_state_onEntry_start, STATE_NAME, and TRACEPOINT().

Referenced by smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::deep_construct().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ static_createEventGenerator()

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
template<typename TEventGenerator , typename... TUArgs>
static std::shared_ptr< smacc2::introspection::EventGeneratorHandler > smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::static_createEventGenerator ( TUArgs...  args)
inlinestatic

Definition at line 271 of file smacc_state_base.hpp.

273 {
274 auto egh = std::make_shared<smacc2::introspection::EventGeneratorHandler>();
275 auto eginfo = std::make_shared<SmaccEventGeneratorInfo>();
276 eginfo->eventGeneratorType = TypeInfo::getTypeInfoFromType<TEventGenerator>();
277
278 eginfo->egh = egh;
279 egh->egInfo_ = eginfo;
280
281 const std::type_info * tindex = &(typeid(MostDerived)); // get identifier of the current state
282
283 if (!SmaccStateInfo::eventGeneratorsInfo.count(tindex))
285 std::vector<std::shared_ptr<SmaccEventGeneratorInfo>>();
286
287 eginfo->factoryFunction = [&, egh, args...](ISmaccState * state)
288 {
289 auto eg = state->createEventGenerator<TEventGenerator>(args...);
290 egh->configureEventGenerator(eg);
291 eg->initialize(state);
292 eg->template onStateAllocation<MostDerived, TEventGenerator>();
293 return eg;
294 };
295
296 SmaccStateInfo::eventGeneratorsInfo[tindex].push_back(eginfo);
297 return egh;
298 }

References smacc2::introspection::SmaccStateInfo::eventGeneratorsInfo.

◆ static_createStateReactor()

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
static std::shared_ptr< smacc2::introspection::StateReactorHandler > smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::static_createStateReactor ( TArgs...  args)
inlinestatic

Definition at line 217 of file smacc_state_base.hpp.

219 {
220 auto srh = std::make_shared<smacc2::introspection::StateReactorHandler>(globalNh_);
221 auto srinfo = std::make_shared<SmaccStateReactorInfo>();
222
223 srinfo->stateReactorType = TypeInfo::getTypeInfoFromType<TStateReactor>();
224 srinfo->outputEventType = TypeInfo::getTypeInfoFromType<TOutputEvent>();
225
226 if (srinfo->outputEventType->templateParameters.size() == 2)
227 {
228 srinfo->objectTagType = srinfo->outputEventType->templateParameters[1];
229 }
230 else if (srinfo->outputEventType->templateParameters.size() == 1)
231 {
232 srinfo->objectTagType = TypeInfo::getTypeInfoFromType<state_reactors::EmptyObjectTag>();
233 }
234 else
235 {
236 assert(
237 false &&
238 "state reactor output events should have one or two parameters (SourceType, ObjectTag)");
239 }
240
241 // iterate statically on all event sources
242 using boost::mpl::_1;
243 using wrappedList = typename boost::mpl::transform<TInputEventList, _1>::type;
244 AddTEventTypeStateReactorInfo<TInputEventList> op(srinfo.get());
245 boost::mpl::for_each<wrappedList>(op);
246
247 srinfo->srh = srh;
248 srh->srInfo_ = srinfo;
249
250 const std::type_info * tindex = &(typeid(MostDerived)); // get identifier of the current state
251
252 if (!SmaccStateInfo::stateReactorsInfo.count(tindex))
254 std::vector<std::shared_ptr<SmaccStateReactorInfo>>();
255
256 srinfo->factoryFunction = [&, srh, args...](ISmaccState * state)
257 {
258 auto sr =
259 state->createStateReactor<TStateReactor, TOutputEvent, TInputEventList, TArgs...>(args...);
260 srh->configureStateReactor(sr);
261 sr->initialize(state);
262 return sr;
263 };
264
265 SmaccStateInfo::stateReactorsInfo[tindex].push_back(srinfo);
266
267 return srh;
268 }
rclcpp::Node::SharedPtr globalNh_

References smacc2::introspection::globalNh_, and smacc2::introspection::SmaccStateInfo::stateReactorsInfo.

◆ static_createStateReactor_aux()

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
template<typename TStateReactor , typename... TUArgs>
static std::shared_ptr< smacc2::introspection::StateReactorHandler > smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::static_createStateReactor_aux ( TUArgs...  args)
inlinestatic

Definition at line 301 of file smacc_state_base.hpp.

303 {
304 auto srh = std::make_shared<smacc2::introspection::StateReactorHandler>(globalNh_);
305 auto srinfo = std::make_shared<SmaccStateReactorInfo>();
306
307 srinfo->stateReactorType = TypeInfo::getTypeInfoFromType<TStateReactor>();
308 srinfo->srh = srh;
309 srh->srInfo_ = srinfo;
310
311 const std::type_info * tindex = &(typeid(MostDerived)); // get identifier of the current state
312
313 if (!SmaccStateInfo::stateReactorsInfo.count(tindex))
315 std::vector<std::shared_ptr<SmaccStateReactorInfo>>();
316
317 srinfo->factoryFunction = [&, srh, args...](ISmaccState * state)
318 {
319 auto sr = state->createStateReactor<TStateReactor>(args...);
320 srh->configureStateReactor(sr);
321 sr->initialize(state);
322 return sr;
323 };
324
325 SmaccStateInfo::stateReactorsInfo[tindex].push_back(srinfo);
326
327 return srh;
328 }

References smacc2::introspection::globalNh_, and smacc2::introspection::SmaccStateInfo::stateReactorsInfo.

◆ throwSequenceFinishedEvent()

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
void smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::throwSequenceFinishedEvent ( )
inline

Definition at line 348 of file smacc_state_base.hpp.

348{ this->postEvent<EvSequenceFinished<MostDerived>>(); }

Member Data Documentation

◆ finishStateThrown

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
bool smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::finishStateThrown

◆ smacc_inner_type

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
InnerInitial* smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::smacc_inner_type

Definition at line 52 of file smacc_state_base.hpp.


The documentation for this class was generated from the following file: