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 359 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 358 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 360 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 357 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:62
#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 332 of file smacc_state_base.hpp.

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

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

206 {
208 [=](ISmaccState * state)
209 {
210 // auto bh = std::make_shared<TBehavior>(args...);
211 state->configure<TOrthogonal, TBehavior>(args...);
212 });
213 }
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 394 of file smacc_state_base.hpp.

396 {
397 ClientBehaviorInfoEntry bhinfo;
398 bhinfo.factoryFunction = initializationFunction;
399
400 bhinfo.behaviorType = &(typeid(TBehavior));
401 bhinfo.orthogonalType = &(typeid(TOrthogonal));
402
403 const std::type_info * tindex = &(typeid(MostDerived));
404 if (!SmaccStateInfo::staticBehaviorInfo.count(tindex))
405 SmaccStateInfo::staticBehaviorInfo[tindex] = std::vector<ClientBehaviorInfoEntry>();
406
407 SmaccStateInfo::staticBehaviorInfo[tindex].push_back(bhinfo);
408 RCLCPP_INFO_STREAM(
409 rclcpp::get_logger("static"), "[states walking] State "
411 << "client behavior count: "
412 << SmaccStateInfo::staticBehaviorInfo[tindex].size());
413 }
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 192 of file smacc_state_base.hpp.

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

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

181 {
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 }

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

370 {
371 const inner_context_ptr_type pInnerContext(shallow_construct(pContext, outermostContextBase));
372 base_type::template deep_construct_inner<inner_initial_list>(
373 pInnerContext, outermostContextBase);
374 }
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 415 of file smacc_state_base.hpp.

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

363 {
364 deep_construct(&outermostContextBase, outermostContextBase);
365 }
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>
template<typename SmaccComponentType >
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 376 of file smacc_state_base.hpp.

378 {
379 // allocating in memory
380 auto state = new MostDerived(
381 SmaccState<MostDerived, Context, InnerInitial, historyMode>::my_context(pContext));
382 const inner_context_ptr_type pInnerContext(state);
383
384 TRACETOOLS_TRACEPOINT(smacc2_state_onEntry_start, STATE_NAME);
385 state->entryStateInternal();
386 TRACETOOLS_TRACEPOINT(smacc2_state_onEntry_end, STATE_NAME);
387
388 outermostContextBase.add(pInnerContext);
389 return pInnerContext;
390 }
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 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
293 eg->template onStateOrthogonalAllocation<MostDerived, TEventGenerator>();
294 eg->template onStateOrthogonalAllocation<MostDerived, TEventGenerator>();
295 return eg;
296 };
297
298 SmaccStateInfo::eventGeneratorsInfo[tindex].push_back(eginfo);
299 return egh;
300 }
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 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 {
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::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 303 of file smacc_state_base.hpp.

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

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 350 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: