SMACC2
Loading...
Searching...
No Matches
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< TBehavior > configure (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< TStateReactor > createStateReactor (TEvArgs... args)
 
template<typename TStateReactor , typename... TEvArgs>
std::shared_ptr< TStateReactor > createStateReactor (TEvArgs... args)
 
template<typename TEventGenerator , typename... TEvArgs>
std::shared_ptr< TEventGenerator > createEventGenerator (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 >
TOrthogonal * getOrthogonal ()
 
template<typename TOrthogonal , typename TClientBehavior >
TClientBehavior * getClientBehavior (int index=0)
 
template<typename TEventGenerator >
TEventGenerator * getEventGenerator ()
 
template<typename TStateReactor >
TStateReactor * getStateReactor ()
 

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
 
InnerInitial * smacc_inner_type
 

Private Types

typedef sc::simple_state< MostDerived, Context, InnerInitial, historyMode > base_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>
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>
base_type::context_ptr_type smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::context_ptr_type

Definition at line 346 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>
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>
base_type::inner_context_ptr_type smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::inner_context_ptr_type

Definition at line 345 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>
base_type::inner_initial_list smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::inner_initial_list

Definition at line 347 of file smacc_state_base.hpp.

◆ LastDeepState

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
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>
base_type::outermost_context_base_type smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::outermost_context_base_type

Definition at line 344 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>
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>
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 }
rclcpp::Node::SharedPtr getNode()
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:61
#define STATE_NAME

References smacc2::utils::cleanShortTypeName(), smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::finishStateThrown, smacc2::ISmaccState::getLogger(), smacc2::ISmaccStateMachine::getNode(), smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::getStateInfo(), smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::getStateMachine(), smacc2::ISmaccState::logger_, smacc2::ISmaccState::node_, smacc2::ISmaccState::parentState_, smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::my_context::pContext_, 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 319 of file smacc_state_base.hpp.

320 {
321 auto * thisobject = static_cast<MostDerived *>(this);
322 auto condition = boost::bind(conditionFn, thisobject);
323 bool conditionResult = condition();
324
325 // RCLCPP_INFO("LOOP EVENT CONDITION: %d", conditionResult);
326 if (conditionResult)
327 {
329 }
330 else
331 {
333 }
334 RCLCPP_INFO(getLogger(), "[%s] POST THROW CONDITION", STATE_NAME);
335 }

References smacc2::ISmaccState::getLogger(), smacc2::ISmaccState::postEvent(), 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 196 of file smacc_state_base.hpp.

197 {
199 [=](ISmaccState * state) { state->configure<TOrthogonal, TBehavior>(args...); });
200 }
static void configure_orthogonal_internal(std::function< void(ISmaccState *state)> initializationFunction)

References smacc2::ISmaccState::configure(), and smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::configure_orthogonal_internal().

Here is the call graph for this function:

◆ configure_orthogonal_internal()

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
template<typename TOrthogonal , typename TBehavior >
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 381 of file smacc_state_base.hpp.

383 {
384 ClientBehaviorInfoEntry bhinfo;
385 bhinfo.factoryFunction = initializationFunction;
386
387 bhinfo.behaviorType = &(typeid(TBehavior));
388 bhinfo.orthogonalType = &(typeid(TOrthogonal));
389
390 const std::type_info * tindex = &(typeid(MostDerived));
391 if (!SmaccStateInfo::staticBehaviorInfo.count(tindex))
392 SmaccStateInfo::staticBehaviorInfo[tindex] = std::vector<ClientBehaviorInfoEntry>();
393
394 SmaccStateInfo::staticBehaviorInfo[tindex].push_back(bhinfo);
395 RCLCPP_INFO_STREAM(
396 rclcpp::get_logger("static"), "[states walking] State "
398 << "client behavior count: "
399 << SmaccStateInfo::staticBehaviorInfo[tindex].size());
400 }
static std::map< const std::type_info *, std::vector< ClientBehaviorInfoEntry > > staticBehaviorInfo

References smacc2::introspection::ClientBehaviorInfoEntry::behaviorType, smacc2::utils::cleanShortTypeName(), smacc2::introspection::ClientBehaviorInfoEntry::factoryFunction, smacc2::introspection::ClientBehaviorInfoEntry::orthogonalType, and smacc2::introspection::SmaccStateInfo::staticBehaviorInfo.

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

Here is the call graph for this function:
Here is the caller 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>
template<typename TOrthogonal , typename TBehavior >
static void smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::configure_orthogonal_runtime ( std::function< void(TBehavior &bh)> initializationFunction)
inlinestatic

Definition at line 184 of file smacc_state_base.hpp.

186 {
188 [=](ISmaccState * state)
189 {
190 auto bh = state->configure<TOrthogonal, TBehavior>();
191 initializationFunction(*bh);
192 });
193 }

References smacc2::ISmaccState::configure(), and smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::configure_orthogonal_internal().

Here is the call graph for this function:

◆ configure_orthogonal_runtime() [2/2]

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

Definition at line 172 of file smacc_state_base.hpp.

174 {
176 [=](ISmaccState * state)
177 {
178 auto bh = state->configure<TOrthogonal, TBehavior>();
179 initializationFunction(*bh, *(static_cast<MostDerived *>(state)));
180 });
181 }

References smacc2::ISmaccState::configure(), and smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::configure_orthogonal_internal().

Here is the call graph for this function:

◆ 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 355 of file smacc_state_base.hpp.

357 {
358 const inner_context_ptr_type pInnerContext(shallow_construct(pContext, outermostContextBase));
359 base_type::template deep_construct_inner<inner_initial_list>(
360 pInnerContext, outermostContextBase);
361 }
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 402 of file smacc_state_base.hpp.

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

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 118 of file smacc_state_base.hpp.

119 {
120 auto * derivedThis = static_cast<MostDerived *>(this);
121 {
122 std::lock_guard<std::recursive_mutex> lock(this->getStateMachine().getMutex());
123 this->getStateMachine().notifyOnStateExiting(derivedThis);
124 try
125 {
126 TRACETOOLS_TRACEPOINT(smacc2_state_onExit_start, STATE_NAME);
127 standardOnExit(*derivedThis);
128 TRACETOOLS_TRACEPOINT(smacc2_state_onExit_end, STATE_NAME);
129 }
130 catch (...)
131 {
132 }
133 this->getStateMachine().notifyOnStateExited(derivedThis);
134 }
135 }
void notifyOnStateExited(StateType *state)
void notifyOnStateExiting(StateType *state)
void standardOnExit(TState &st, std::true_type)
smacc2_state_onExit_end
smacc2_state_onExit_start

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

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 151 of file smacc_state_base.hpp.

152 {
153 return base_type::outermost_context().getGlobalSMData(name, ret);
154 }

◆ 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.

115{ return parentState_; }

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 }
const SmaccStateMachineInfo & getStateMachineInfo()

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

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 349 of file smacc_state_base.hpp.

350 {
351 deep_construct(&outermostContextBase, outermostContextBase);
352 }
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 144 of file smacc_state_base.hpp.

144{}

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 148 of file smacc_state_base.hpp.

148{}

◆ requiresComponent()

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

Definition at line 164 of file smacc_state_base.hpp.

165 {
166 base_type::outermost_context().requiresComponent(storage);
167 }

◆ 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 140 of file smacc_state_base.hpp.

140{}

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 158 of file smacc_state_base.hpp.

159 {
160 base_type::outermost_context().setGlobalSMData(name, value);
161 }

◆ 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 363 of file smacc_state_base.hpp.

365 {
366 // allocating in memory
367 auto state = new MostDerived(
368 SmaccState<MostDerived, Context, InnerInitial, historyMode>::my_context(pContext));
369 const inner_context_ptr_type pInnerContext(state);
370
371 TRACETOOLS_TRACEPOINT(smacc2_state_onEntry_start, STATE_NAME);
372 state->entryStateInternal();
373 TRACETOOLS_TRACEPOINT(smacc2_state_onEntry_end, STATE_NAME);
374
375 outermostContextBase.add(pInnerContext);
376 return pInnerContext;
377 }
smacc2_state_onEntry_end
smacc2_state_onEntry_start

References smacc2_state_onEntry_end, smacc2_state_onEntry_start, and STATE_NAME.

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

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 258 of file smacc_state_base.hpp.

260 {
261 auto egh = std::make_shared<smacc2::introspection::EventGeneratorHandler>();
262 auto eginfo = std::make_shared<SmaccEventGeneratorInfo>();
263 eginfo->eventGeneratorType = TypeInfo::getTypeInfoFromType<TEventGenerator>();
264
265 eginfo->egh = egh;
266 egh->egInfo_ = eginfo;
267
268 const std::type_info * tindex = &(typeid(MostDerived)); // get identifier of the current state
269
270 if (!SmaccStateInfo::eventGeneratorsInfo.count(tindex))
272 std::vector<std::shared_ptr<SmaccEventGeneratorInfo>>();
273
274 eginfo->factoryFunction = [&, egh, args...](ISmaccState * state)
275 {
276 auto eg = state->createEventGenerator<TEventGenerator>(args...);
277 egh->configureEventGenerator(eg);
278 eg->initialize(state);
279
280 eg->template onStateOrthogonalAllocation<MostDerived, TEventGenerator>();
281 eg->template onStateOrthogonalAllocation<MostDerived, TEventGenerator>();
282 return eg;
283 };
284
285 SmaccStateInfo::eventGeneratorsInfo[tindex].push_back(eginfo);
286 return egh;
287 }
static TypeInfo::Ptr getTypeInfoFromType()

References smacc2::introspection::SmaccStateInfo::eventGeneratorsInfo, and smacc2::introspection::TypeInfo::getTypeInfoFromType().

Here is the call graph for this function:

◆ static_createStateReactor()

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

Definition at line 204 of file smacc_state_base.hpp.

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

References smacc2::introspection::TypeInfo::getTypeInfoFromType(), smacc2::introspection::globalNh_, and smacc2::introspection::SmaccStateInfo::stateReactorsInfo.

Here is the call graph for this function:

◆ 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 290 of file smacc_state_base.hpp.

292 {
293 auto srh = std::make_shared<smacc2::introspection::StateReactorHandler>(globalNh_);
294 auto srinfo = std::make_shared<SmaccStateReactorInfo>();
295
296 srinfo->stateReactorType = TypeInfo::getTypeInfoFromType<TStateReactor>();
297 srinfo->srh = srh;
298 srh->srInfo_ = srinfo;
299
300 const std::type_info * tindex = &(typeid(MostDerived)); // get identifier of the current state
301
302 if (!SmaccStateInfo::stateReactorsInfo.count(tindex))
304 std::vector<std::shared_ptr<SmaccStateReactorInfo>>();
305
306 srinfo->factoryFunction = [&, srh, args...](ISmaccState * state)
307 {
308 auto sr = state->createStateReactor<TStateReactor>(args...);
309 srh->configureStateReactor(sr);
310 sr->initialize(state);
311 return sr;
312 };
313
314 SmaccStateInfo::stateReactorsInfo[tindex].push_back(srinfo);
315
316 return srh;
317 }

References smacc2::introspection::TypeInfo::getTypeInfoFromType(), smacc2::introspection::globalNh_, and smacc2::introspection::SmaccStateInfo::stateReactorsInfo.

Here is the call graph for this function:

◆ 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 337 of file smacc_state_base.hpp.

References smacc2::ISmaccState::postEvent().

Here is the call graph for this function:

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: