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

#include <smacc_state_base.h>

Inheritance diagram for smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >:
Inheritance graph
Collaboration diagram for smacc::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 smacc::introspection::SmaccStateInfogetStateInfo ()
 
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 smacc::ISmaccState
virtual ISmaccStateMachinegetStateMachine ()=0
 
ISmaccStategetParentState ()
 
ros::NodeHandle & getROSNode ()
 
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< smacc::introspection::TypeInfo > &transitionTypeInfo)
 
std::vector< std::shared_ptr< StateReactor > > & getStateReactors ()
 
std::vector< std::shared_ptr< SmaccEventGenerator > > & getEventGenerators ()
 
template<typename T >
bool getParam (std::string param_name, T &param_storage)
 
template<typename T >
void setParam (std::string param_name, T param_val)
 
template<typename T >
bool param (std::string param_name, T &param_val, const T &default_val) const
 
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< smacc::introspection::StateReactorHandlerstatic_createStateReactor (TArgs... args)
 
template<typename TEventGenerator , typename... TUArgs>
static std::shared_ptr< smacc::introspection::EventGeneratorHandlerstatic_createEventGenerator (TUArgs... args)
 
template<typename TStateReactor , typename... TUArgs>
static std::shared_ptr< smacc::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 smacc::ISmaccState
std::vector< std::shared_ptr< StateReactor > > stateReactors_
 
std::vector< std::shared_ptr< smacc::SmaccEventGenerator > > eventGenerators_
 
ros::NodeHandle nh
 
ros::NodeHandle contextNh
 
ISmaccStateparentState_
 
const smacc::introspection::SmaccStateInfostateInfo_
 

Detailed Description

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

Definition at line 22 of file smacc_state_base.h.

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> smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::base_type
private

Definition at line 27 of file smacc_state_base.h.

◆ 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 smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::context_ptr_type

Definition at line 339 of file smacc_state_base.h.

◆ context_type

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

Definition at line 31 of file smacc_state_base.h.

◆ 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 smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::inner_context_ptr_type

Definition at line 338 of file smacc_state_base.h.

◆ 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 smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::inner_initial_list

Definition at line 340 of file smacc_state_base.h.

◆ LastDeepState

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

Definition at line 34 of file smacc_state_base.h.

◆ 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 smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::outermost_context_base_type

Definition at line 337 of file smacc_state_base.h.

◆ state_iterator

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

Definition at line 32 of file smacc_state_base.h.

◆ TContext

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

Definition at line 30 of file smacc_state_base.h.

Constructor & Destructor Documentation

◆ SmaccState() [1/2]

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
smacc::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>
smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::SmaccState ( my_context  ctx)
inline

Definition at line 53 of file smacc_state_base.h.

54 {
55 static_assert(std::is_base_of<ISmaccState, Context>::value || std::is_base_of<ISmaccStateMachine, Context>::value, "The context class must be a SmaccState or a SmaccStateMachine");
56
57 static_assert(!std::is_same<MostDerived, Context>::value, "The context must be a different state or state machine than the current state");
58
59 ROS_WARN("[%s] creating ", STATE_NAME);
60 this->set_context(ctx.pContext_);
61
62 this->stateInfo_ = getStateInfo();
63
64 // storing a reference to the parent state
65 auto &ps = this->template context<Context>();
66 parentState_ = dynamic_cast<ISmaccState *>(&ps);
67 finishStateThrown = false;
68
69 this->contextNh = optionalNodeHandle(ctx.pContext_);
70 ROS_DEBUG("[%s] Ros node handle namespace for this state: %s", STATE_NAME, contextNh.getNamespace().c_str());
71 if (contextNh.getNamespace() == "/")
72 {
73 auto nhname = smacc::utils::cleanShortTypeName(typeid(Context));
74 ROS_INFO("[%s] Creating ros NodeHandle for this state: %s", STATE_NAME, nhname.c_str());
75 contextNh = ros::NodeHandle(nhname);
76 }
77 }
ISmaccState * parentState_
Definition: smacc_state.h:93
ros::NodeHandle contextNh
Definition: smacc_state.h:91
const smacc::introspection::SmaccStateInfo * stateInfo_
Definition: smacc_state.h:95
const smacc::introspection::SmaccStateInfo * getStateInfo()
auto optionalNodeHandle(boost::intrusive_ptr< T > &obj) -> ros::NodeHandle
Definition: introspection.h:39
std::string cleanShortTypeName(const std::type_info &tinfo)
Definition: common.cpp:14
#define STATE_NAME

References smacc::utils::cleanShortTypeName(), smacc::ISmaccState::contextNh, smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::finishStateThrown, smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::getStateInfo(), smacc::introspection::optionalNodeHandle(), smacc::ISmaccState::parentState_, smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::my_context::pContext_, STATE_NAME, and smacc::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 smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::~SmaccState ( )
inlinevirtual

Definition at line 79 of file smacc_state_base.h.

80 {
81 }

Member Function Documentation

◆ checkWhileLoopConditionAndThrowEvent()

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

Definition at line 308 of file smacc_state_base.h.

309 {
310 auto *thisobject = static_cast<MostDerived *>(this);
311 auto condition = boost::bind(conditionFn, thisobject);
312 bool conditionResult = condition();
313
314 //ROS_INFO("LOOP EVENT CONDITION: %d", conditionResult);
315 if (conditionResult)
316 {
317 this->postEvent<EvLoopContinue<MostDerived>>();
318 }
319 else
320 {
321 this->postEvent<EvLoopEnd<MostDerived>>();
322 }
323 ROS_INFO("[%s] POST THROW CONDITION", STATE_NAME);
324 }

References STATE_NAME.

◆ 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 smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::configure_orthogonal ( Args &&...  args)
inlinestatic

Definition at line 194 of file smacc_state_base.h.

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

References smacc::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 smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::configure_orthogonal_internal ( std::function< void(ISmaccState< MostDerived, Context, InnerInitial, historyMode > *state)>  initializationFunction)
inlinestaticprivate

Definition at line 376 of file smacc_state_base.h.

377 {
378 ROS_INFO("[%s] Runtime configure orthogonal %s -> %s", STATE_NAME, demangleSymbol(typeid(TOrthogonal).name()).c_str(), demangleSymbol(typeid(TBehavior).name()).c_str());
379
380 ClientBehaviorInfoEntry bhinfo;
381 bhinfo.factoryFunction = initializationFunction;
382
383 bhinfo.behaviorType = &(typeid(TBehavior));
384 bhinfo.orthogonalType = &(typeid(TOrthogonal));
385
386 const std::type_info *tindex = &(typeid(MostDerived));
387 if (!SmaccStateInfo::staticBehaviorInfo.count(tindex))
388 SmaccStateInfo::staticBehaviorInfo[tindex] = std::vector<ClientBehaviorInfoEntry>();
389
390 SmaccStateInfo::staticBehaviorInfo[tindex].push_back(bhinfo);
391 }
static std::map< const std::type_info *, std::vector< ClientBehaviorInfoEntry > > staticBehaviorInfo
std::string demangleSymbol()
Definition: introspection.h:75

References smacc::introspection::ClientBehaviorInfoEntry::behaviorType, smacc::introspection::demangleSymbol(), smacc::introspection::ClientBehaviorInfoEntry::factoryFunction, smacc::introspection::ClientBehaviorInfoEntry::orthogonalType, STATE_NAME, and smacc::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 smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::configure_orthogonal_runtime ( std::function< void(TBehavior &bh)>  initializationFunction)
inlinestatic

Definition at line 184 of file smacc_state_base.h.

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

References smacc::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 smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::configure_orthogonal_runtime ( std::function< void(TBehavior &bh, MostDerived &)>  initializationFunction)
inlinestatic

Definition at line 174 of file smacc_state_base.h.

175 {
176 configure_orthogonal_internal<TOrthogonal, TBehavior>([=](ISmaccState *state) {
177 //auto bh = std::make_shared<TBehavior>(args...);
178 auto bh = state->configure<TOrthogonal, TBehavior>();
179 initializationFunction(*bh, *(static_cast<MostDerived *>(state)));
180 });
181 }

References smacc::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 smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::deep_construct ( const context_ptr_type pContext,
outermost_context_base_type outermostContextBase 
)
inlinestatic

Definition at line 349 of file smacc_state_base.h.

352 {
353 const inner_context_ptr_type pInnerContext(
354 shallow_construct(pContext, outermostContextBase));
355 base_type::template deep_construct_inner<inner_initial_list>(
356 pInnerContext, outermostContextBase);
357 }
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 smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::shallow_construct().

Referenced by smacc::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 smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::entryStateInternal ( )
inlineprivate

Definition at line 393 of file smacc_state_base.h.

394 {
395 this->getStateMachine().notifyOnStateEntryStart(static_cast<MostDerived *>(this));
396
397 // TODO: make this static to build the parameter tree at startup
398 this->nh = ros::NodeHandle(contextNh.getNamespace() + std::string("/") + smacc::utils::cleanShortTypeName(typeid(MostDerived)).c_str());
399
400 ROS_DEBUG("[%s] nodehandle namespace: %s", STATE_NAME, nh.getNamespace().c_str());
401
402 this->setParam("created", true);
403
404 // before dynamic runtimeConfigure, we execute the staticConfigure behavior configurations
405 {
406 ROS_INFO("[%s] -- STATIC STATE DESCRIPTION --", STATE_NAME);
407
408 for (const auto &stateReactorsVector : SmaccStateInfo::staticBehaviorInfo)
409 {
410 ROS_DEBUG("[%s] state info: %s", STATE_NAME, demangleSymbol(stateReactorsVector.first->name()).c_str());
411 for (auto &bhinfo : stateReactorsVector.second)
412 {
413 ROS_DEBUG("[%s] client behavior: %s", STATE_NAME, demangleSymbol(bhinfo.behaviorType->name()).c_str());
414 }
415 }
416
417 const std::type_info *tindex = &(typeid(MostDerived));
418 auto &staticDefinedBehaviors = SmaccStateInfo::staticBehaviorInfo[tindex];
419 auto &staticDefinedStateReactors = SmaccStateInfo::stateReactorsInfo[tindex];
420 auto &staticDefinedEventGenerators = SmaccStateInfo::eventGeneratorsInfo[tindex];
421
422 for(auto & ortho : this->getStateMachine().getOrthogonals())
423 {
424 ROS_INFO("[%s] Initializing orthogonal: %s", STATE_NAME, demangleSymbol(typeid(*ortho.second).name()).c_str());
425 ortho.second->initState(this);
426 }
427
428 for (auto &bhinfo : staticDefinedBehaviors)
429 {
430 ROS_INFO("[%s] Creating static client behavior: %s", STATE_NAME, demangleSymbol(bhinfo.behaviorType->name()).c_str());
431 bhinfo.factoryFunction(this);
432 }
433
434 for (auto &sr : staticDefinedStateReactors)
435 {
436 ROS_INFO("[%s] Creating static state reactor: %s", STATE_NAME, demangleSymbol(sr->stateReactorType->name()).c_str());
437 sr->factoryFunction(this);
438 }
439
440 for (auto &eg : staticDefinedEventGenerators)
441 {
442 ROS_INFO("[%s] Creating static event generator: %s", STATE_NAME, demangleSymbol(eg->eventGeneratorType->name()).c_str());
443 eg->factoryFunction(this);
444 }
445
446 ROS_INFO("[%s] ---- END STATIC DESCRIPTION", STATE_NAME);
447 }
448
449 ROS_INFO("[%s] State runtime configuration", STATE_NAME);
450
451 auto *derivedthis = static_cast<MostDerived *>(this);
452
453 // second the orthogonals are internally configured
454 this->getStateMachine().notifyOnRuntimeConfigured(derivedthis);
455
456 // first we runtime configure the state, where we create client behaviors
457 static_cast<MostDerived *>(this)->runtimeConfigure();
458
460
461 ROS_INFO("[%s] State OnEntry", STATE_NAME);
462
463 // finally we go to the derived state onEntry Function
464 static_cast<MostDerived *>(this)->onEntry();
465
466 // here orthogonals and client behaviors are entered OnEntry
467 this->getStateMachine().notifyOnStateEntryEnd(derivedthis);
468 }
void notifyOnRuntimeConfigurationFinished(StateType *state)
void notifyOnRuntimeConfigured(StateType *state)
const std::map< std::string, std::shared_ptr< smacc::ISmaccOrthogonal > > & getOrthogonals() const
void notifyOnStateEntryEnd(StateType *state)
void notifyOnStateEntryStart(StateType *state)
void setParam(std::string param_name, T param_val)
ros::NodeHandle nh
Definition: smacc_state.h:89
virtual ISmaccStateMachine & getStateMachine()
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

References smacc::utils::cleanShortTypeName(), smacc::ISmaccState::contextNh, smacc::introspection::demangleSymbol(), smacc::introspection::SmaccStateInfo::eventGeneratorsInfo, smacc::ISmaccStateMachine::getOrthogonals(), smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::getStateMachine(), smacc::ISmaccState::nh, smacc::ISmaccStateMachine::notifyOnRuntimeConfigurationFinished(), smacc::ISmaccStateMachine::notifyOnRuntimeConfigured(), smacc::ISmaccStateMachine::notifyOnStateEntryEnd(), smacc::ISmaccStateMachine::notifyOnStateEntryStart(), smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::onEntry(), smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::runtimeConfigure(), smacc::ISmaccState::setParam(), STATE_NAME, smacc::introspection::SmaccStateInfo::stateReactorsInfo, and smacc::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 smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::exit ( )
inline

Definition at line 116 of file smacc_state_base.h.

117 {
118 auto *derivedThis = static_cast<MostDerived *>(this);
119 this->getStateMachine().notifyOnStateExitting(derivedThis);
120 try
121 { // static_cast<MostDerived *>(this)->onExit();
122 standardOnExit(*derivedThis);
123 }
124 catch (...)
125 {
126 }
127 this->getStateMachine().notifyOnStateExited(derivedThis);
128 }
void notifyOnStateExitting(StateType *state)
void notifyOnStateExited(StateType *state)
void standardOnExit(TState &st, std::true_type)
Definition: state_traits.h:62

References smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::getStateMachine(), smacc::ISmaccStateMachine::notifyOnStateExited(), smacc::ISmaccStateMachine::notifyOnStateExitting(), and smacc::standardOnExit().

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 smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::getFullName ( )
inline

Definition at line 98 of file smacc_state_base.h.

99 {
100 return demangleSymbol(typeid(MostDerived).name());
101 }

References smacc::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 smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::getGlobalSMData ( std::string  name,
T &  ret 
)
inline

Definition at line 150 of file smacc_state_base.h.

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

◆ getParentState()

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

Definition at line 108 of file smacc_state_base.h.

109 {
110 //auto* ctx = dynamic_cast<ISmaccState*>(this->template context<Context *>());
111
112 return parentState_;
113 }

References smacc::ISmaccState::parentState_.

◆ getShortName()

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

Definition at line 103 of file smacc_state_base.h.

104 {
105 return smacc::utils::cleanShortTypeName(typeid(MostDerived));
106 }

References smacc::utils::cleanShortTypeName().

Here is the call graph for this function:

◆ getStateInfo()

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

Definition at line 83 of file smacc_state_base.h.

84 {
85 auto smInfo = this->getStateMachine().getStateMachineInfo();
86
87 auto key = typeid(MostDerived).name();
88 if (smInfo.states.count(key))
89 {
90 return smInfo.states[key].get();
91 }
92 else
93 {
94 return nullptr;
95 }
96 }
const SmaccStateMachineInfo & getStateMachineInfo()
std::map< std::string, std::shared_ptr< SmaccStateInfo > > states

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

Referenced by smacc::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 & smacc::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 smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::initial_deep_construct ( outermost_context_base_type outermostContextBase)
inlinestatic

Definition at line 342 of file smacc_state_base.h.

344 {
345 deep_construct(&outermostContextBase, outermostContextBase);
346 }
static void deep_construct(const context_ptr_type &pContext, outermost_context_base_type &outermostContextBase)

References smacc::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 smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::onEntry ( )
inline

Definition at line 139 of file smacc_state_base.h.

140 {
141 }

Referenced by smacc::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 smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::onExit ( )
inline

Definition at line 145 of file smacc_state_base.h.

146 {
147 }

◆ requiresComponent()

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

Definition at line 163 of file smacc_state_base.h.

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

◆ runtimeConfigure()

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

Definition at line 133 of file smacc_state_base.h.

134 {
135 }

Referenced by smacc::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 smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::setGlobalSMData ( std::string  name,
value 
)
inline

Definition at line 157 of file smacc_state_base.h.

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

◆ shallow_construct()

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

Definition at line 359 of file smacc_state_base.h.

362 {
363 // allocating in memory
364 auto state = new MostDerived(SmaccState<MostDerived, Context, InnerInitial, historyMode>::my_context(pContext));
365 const inner_context_ptr_type pInnerContext(state);
366
367 ROS_INFO("[%s] State object created. Initializating...", STATE_NAME);
368 state->entryStateInternal();
369
370 outermostContextBase.add(pInnerContext);
371 return pInnerContext;
372 }

References STATE_NAME.

Referenced by smacc::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< smacc::introspection::EventGeneratorHandler > smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::static_createEventGenerator ( TUArgs...  args)
inlinestatic

Definition at line 256 of file smacc_state_base.h.

257 {
258 auto egh = std::make_shared<smacc::introspection::EventGeneratorHandler>();
259 auto eginfo = std::make_shared<SmaccEventGeneratorInfo>();
260 eginfo->eventGeneratorType = &typeid(TEventGenerator);
261 eginfo->egh = egh;
262 egh->egInfo_ = eginfo;
263
264 const std::type_info *tindex = &(typeid(MostDerived)); // get identifier of the current state
265
266 if (!SmaccStateInfo::eventGeneratorsInfo.count(tindex))
267 SmaccStateInfo::eventGeneratorsInfo[tindex] = std::vector<std::shared_ptr<SmaccEventGeneratorInfo>>();
268
269 eginfo->factoryFunction = [&, egh, args...](ISmaccState *state) {
270 auto eg = state->createEventGenerator<TEventGenerator>(args...);
271 egh->configureEventGenerator(eg);
272 eg->initialize(state);
273 eg->template onStateAllocation<MostDerived, TEventGenerator>();
274 return eg;
275 };
276
277 SmaccStateInfo::eventGeneratorsInfo[tindex].push_back(eginfo);
278 return egh;
279 }

References smacc::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< smacc::introspection::StateReactorHandler > smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::static_createStateReactor ( TArgs...  args)
inlinestatic

Definition at line 229 of file smacc_state_base.h.

230 {
231 auto srh = std::make_shared<smacc::introspection::StateReactorHandler>();
232 auto srinfo = std::make_shared<SmaccStateReactorInfo>();
233
234 srinfo->stateReactorType = &typeid(TStateReactor);
235 srinfo->srh = srh;
236 srh->srInfo_ = srinfo;
237
238 const std::type_info *tindex = &(typeid(MostDerived)); // get identifier of the current state
239
240 if (!SmaccStateInfo::stateReactorsInfo.count(tindex))
241 SmaccStateInfo::stateReactorsInfo[tindex] = std::vector<std::shared_ptr<SmaccStateReactorInfo>>();
242
243 srinfo->factoryFunction = [&, srh, args...](ISmaccState *state) {
244 auto sr = state->createStateReactor<TStateReactor, TOutputEvent, TInputEventList, TArgs...>(args...);
245 srh->configureStateReactor(sr);
246 sr->initialize(state);
247 return sr;
248 };
249
250 SmaccStateInfo::stateReactorsInfo[tindex].push_back(srinfo);
251
252 return srh;
253 }

References smacc::introspection::SmaccStateInfo::stateReactorsInfo.

◆ static_createStateReactor_aux()

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

Definition at line 282 of file smacc_state_base.h.

283 {
284 auto srh = std::make_shared<smacc::introspection::StateReactorHandler>();
285 auto srinfo = std::make_shared<SmaccStateReactorInfo>();
286
287 srinfo->stateReactorType = &typeid(TStateReactor);
288 srinfo->srh = srh;
289 srh->srInfo_ = srinfo;
290
291 const std::type_info *tindex = &(typeid(MostDerived)); // get identifier of the current state
292
293 if (!SmaccStateInfo::stateReactorsInfo.count(tindex))
294 SmaccStateInfo::stateReactorsInfo[tindex] = std::vector<std::shared_ptr<SmaccStateReactorInfo>>();
295
296 srinfo->factoryFunction = [&, srh, args...](ISmaccState *state) {
297 auto sr = state->createStateReactor<TStateReactor>(args...);
298 srh->configureStateReactor(sr);
299 sr->initialize(state);
300 return sr;
301 };
302
303 SmaccStateInfo::stateReactorsInfo[tindex].push_back(srinfo);
304
305 return srh;
306 }

References smacc::introspection::SmaccStateInfo::stateReactorsInfo.

◆ throwSequenceFinishedEvent()

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

Definition at line 326 of file smacc_state_base.h.

327 {
328 this->postEvent<EvSequenceFinished<MostDerived>>();
329 }

Member Data Documentation

◆ finishStateThrown

template<class MostDerived , class Context , class InnerInitial = mpl::list<>, sc::history_mode historyMode = sc::has_deep_history>
bool smacc::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* smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::smacc_inner_type

Definition at line 37 of file smacc_state_base.h.


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