SMACC2
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>

Inherits boost::statechart::simple_state< MostDerived, Context, mpl::list<>, sc::has_deep_history >, and smacc2::ISmaccState.

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
virtual ISmaccStateMachinegetStateMachine ()=0
 
virtual std::string getName ()=0
 
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 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>
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 348 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 347 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 349 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 346 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 }
rclcpp::Node::SharedPtr getNode()
std::shared_ptr< rclcpp::Logger > logger_
Definition: smacc_state.hpp:98
rclcpp::Logger getLogger()
Definition: smacc_state.hpp:36
rclcpp::Node::SharedPtr node_
Definition: smacc_state.hpp:97
ISmaccState * parentState_
const smacc2::introspection::SmaccStateInfo * stateInfo_
virtual ISmaccStateMachine & getStateMachine()
const smacc2::introspection::SmaccStateInfo * getStateInfo()
std::string cleanShortTypeName(const std::type_info &tinfo)
Definition: common.cpp:28
#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 321 of file smacc_state_base.hpp.

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

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

202 {
203 configure_orthogonal_internal<TOrthogonal, TBehavior>([=](ISmaccState * state) {
204 // auto bh = std::make_shared<TBehavior>(args...);
205 state->configure<TOrthogonal, TBehavior>(args...);
206 });
207 }

References generate_debs::args, and smacc2::ISmaccState::configure().

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

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

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

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

References smacc2::ISmaccState::configure().

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

References smacc2::ISmaccState::configure().

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

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

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

References smacc2::ISmaccStateMachine::disposeStateAndDisconnectSignals(), smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::getStateMachine(), smacc2::ISmaccStateMachine::notifyOnStateExited(), smacc2::ISmaccStateMachine::notifyOnStateExitting(), 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(); }
std::string 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()
std::map< std::string, std::shared_ptr< SmaccStateInfo > > states

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

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

352 {
353 deep_construct(&outermostContextBase, outermostContextBase);
354 }
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 365 of file smacc_state_base.hpp.

367 {
368 // allocating in memory
369 auto state = new MostDerived(
371 const inner_context_ptr_type pInnerContext(state);
372
374 state->entryStateInternal();
376
377 outermostContextBase.add(pInnerContext);
378 return pInnerContext;
379 }
boost::statechart::processor_container< boost::statechart::fifo_scheduler<>, boost::function0< void >, std::allocator< boost::statechart::none > >::processor_context my_context
Definition: common.hpp:48
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 264 of file smacc_state_base.hpp.

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

References generate_debs::args, and smacc2::introspection::SmaccStateInfo::eventGeneratorsInfo.

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

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

References generate_debs::args, smacc2::introspection::globalNh_, smacc2::introspection::SmaccStateInfo::stateReactorsInfo, and generate_debs::type.

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

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

References generate_debs::args, 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 339 of file smacc_state_base.hpp.

339{ 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: