SMACC2
Loading...
Searching...
No Matches
smacc2::introspection::SmaccStateInfo Class Reference

#include <smacc_state_info.hpp>

Inheritance diagram for smacc2::introspection::SmaccStateInfo:
Inheritance graph
Collaboration diagram for smacc2::introspection::SmaccStateInfo:
Collaboration graph

Public Types

typedef std::shared_ptr< SmaccStateInfo > Ptr
 

Public Member Functions

 SmaccStateInfo (const std::type_info *tid, std::shared_ptr< SmaccStateInfo > parentState, std::shared_ptr< SmaccStateMachineInfo > stateMachineInfo)
 
SmaccStateType getStateLevel ()
 
std::shared_ptr< SmaccStateMachineInfo > getStateMachineInfo () const
 
std::shared_ptr< SmaccStateInfo > getParentState () const
 
int depth () const
 
void getAncestors (std::list< const SmaccStateInfo * > &ancestorsList) const
 
std::string getFullPath ()
 
template<typename StateType >
std::shared_ptr< SmaccStateInfo > createChildState ()
 
template<typename EvType >
void declareTransition (std::shared_ptr< SmaccStateInfo > &dstState, const std::string &transitionTag, const std::string &transitionType, bool history, TypeInfo::Ptr transitionTypeInfo)
 
const std::string & toShortName () const
 
std::string getDemangledFullName () const
 
rclcpp::Node::SharedPtr getNode ()
 
rclcpp::Logger getLogger ()
 

Public Attributes

int stateIndex_ = 0
 
std::string fullStateName
 
std::string demangledStateName
 
std::weak_ptr< SmaccStateMachineInfo > stateMachine_
 
std::weak_ptr< SmaccStateInfo > parentState_
 
std::vector< SmaccTransitionInfo > transitions_
 
std::vector< std::shared_ptr< SmaccStateInfo > > children_
 
int depth_ = 0
 
const std::type_info * tid_
 

Static Public Attributes

static std::map< const std::type_info *, std::vector< ClientBehaviorInfoEntry > > staticBehaviorInfo
 
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
 

Detailed Description

Definition at line 188 of file smacc_state_info.hpp.

Member Typedef Documentation

◆ Ptr

Constructor & Destructor Documentation

◆ SmaccStateInfo()

smacc2::SmaccStateInfo::SmaccStateInfo ( const std::type_info * tid,
std::shared_ptr< SmaccStateInfo > parentState,
std::shared_ptr< SmaccStateMachineInfo > stateMachineInfo )

Definition at line 37 of file smacc_state_info.cpp.

40: stateMachine_(stateMachineInfo), parentState_(parentState), tid_(tid)
41{
42 if (parentState != nullptr) depth_ = parentState->depth_ + 1;
43}
std::weak_ptr< SmaccStateInfo > parentState_
std::weak_ptr< SmaccStateMachineInfo > stateMachine_

References depth_.

Member Function Documentation

◆ createChildState()

template<typename StateType >
std::shared_ptr< SmaccStateInfo > smacc2::introspection::SmaccStateInfo::createChildState ( )

Definition at line 474 of file smacc_state_machine_info.hpp.

475{
476 auto realparentState = this->getStateMachineInfo()->getState<typename StateType::TContext>();
477
478 auto childState = this->getStateMachineInfo()->createState<StateType>(realparentState);
479
480 RCLCPP_WARN_STREAM(
481 getLogger(), "Real parent state> " << demangleSymbol<typename StateType::TContext>());
482
483 return childState;
484}
std::shared_ptr< SmaccStateMachineInfo > getStateMachineInfo() const
std::string demangleSymbol()

References smacc2::introspection::demangleSymbol(), getLogger(), and getStateMachineInfo().

Here is the call graph for this function:

◆ declareTransition()

template<typename EvType >
void smacc2::introspection::SmaccStateInfo::declareTransition ( std::shared_ptr< SmaccStateInfo > & dstState,
const std::string & transitionTag,
const std::string & transitionType,
bool history,
TypeInfo::Ptr transitionTypeInfo )

Definition at line 255 of file smacc_state_machine_info.hpp.

258{
259 auto evtype = demangledTypeName<EvType>();
260
261 SmaccTransitionInfo transitionInfo;
262 transitionInfo.index = static_cast<int>(transitions_.size());
263 transitionInfo.sourceState = shared_from_this();
264 transitionInfo.destinyState = dstState;
265 transitionInfo.transitionTypeInfo = transitionTypeInfo;
266
267 if (transitionTag != "")
268 transitionInfo.transitionTag = transitionTag;
269 else
270 transitionInfo.transitionTag = "Transition_" + std::to_string(transitionInfo.index);
271
272 transitionInfo.transitionType = transitionType;
273 transitionInfo.historyNode = history;
274
275 transitionInfo.eventInfo =
276 std::make_shared<SmaccEventInfo>(transitionTypeInfo->templateParameters.front());
277
278 EventLabel<EvType>(transitionInfo.eventInfo->label);
279 // RCLCPP_DEBUG_STREAM(getLogger(), "LABEL: " << transitionInfo.eventInfo->label);
280
281 transitions_.push_back(transitionInfo);
282}
std::vector< SmaccTransitionInfo > transitions_
std::enable_if< HasEventLabel< T >::value, void >::type EventLabel(std::string &label)
std::string demangledTypeName()

References smacc2::introspection::demangledTypeName(), smacc2::introspection::SmaccTransitionInfo::destinyState, smacc2::introspection::SmaccTransitionInfo::eventInfo, smacc2::introspection::EventLabel(), smacc2::introspection::SmaccTransitionInfo::historyNode, smacc2::introspection::SmaccTransitionInfo::index, smacc2::introspection::SmaccTransitionInfo::sourceState, transitions_, smacc2::introspection::SmaccTransitionInfo::transitionTag, smacc2::introspection::SmaccTransitionInfo::transitionType, and smacc2::introspection::SmaccTransitionInfo::transitionTypeInfo.

Here is the call graph for this function:

◆ depth()

int smacc2::introspection::SmaccStateInfo::depth ( ) const
inline

Definition at line 229 of file smacc_state_info.hpp.

229{ return depth_; }

References depth_.

◆ getAncestors()

void smacc2::SmaccStateInfo::getAncestors ( std::list< const SmaccStateInfo * > & ancestorsList) const

Definition at line 45 of file smacc_state_info.cpp.

46{
47 ancestorsList.push_front(this);
48 auto parent = parentState_.lock();
49 if (parent != nullptr)
50 {
51 parent->getAncestors(ancestorsList);
52 }
53}

References parentState_.

◆ getDemangledFullName()

std::string smacc2::SmaccStateInfo::getDemangledFullName ( ) const

Definition at line 97 of file smacc_state_info.cpp.

98{
99 return demangleSymbol(this->fullStateName.c_str());
100}

References smacc2::introspection::demangleSymbol(), and fullStateName.

Here is the call graph for this function:

◆ getFullPath()

std::string smacc2::SmaccStateInfo::getFullPath ( )

Definition at line 86 of file smacc_state_info.cpp.

87{
88 auto parent = parentState_.lock();
89 if (parent == nullptr)
90 return this->toShortName();
91 else
92 return parent->getFullPath() + "/" + this->toShortName();
93}
const std::string & toShortName() const

References parentState_, and toShortName().

Here is the call graph for this function:

◆ getLogger()

rclcpp::Logger smacc2::introspection::SmaccStateInfo::getLogger ( )
inline

Definition at line 247 of file smacc_state_info.hpp.

247{ return getNode()->get_logger(); }

References getNode().

Referenced by createChildState().

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

◆ getNode()

rclcpp::Node::SharedPtr smacc2::SmaccStateInfo::getNode ( )

Definition at line 74 of file smacc_state_info.cpp.

75{
76 auto stateMachineInfo = this->stateMachine_.lock();
77 if (stateMachineInfo == nullptr)
78 {
79 throw std::runtime_error(
80 "SmaccStateInfo::getNode: the SmaccStateMachineInfo that owns state '" +
81 this->demangledStateName + "' has been destroyed");
82 }
83 return stateMachineInfo->getNode();
84}

References demangledStateName, and stateMachine_.

Referenced by getLogger().

Here is the caller graph for this function:

◆ getParentState()

std::shared_ptr< SmaccStateInfo > smacc2::introspection::SmaccStateInfo::getParentState ( ) const
inline

Definition at line 227 of file smacc_state_info.hpp.

227{ return parentState_.lock(); }

References parentState_.

◆ getStateLevel()

SmaccStateType smacc2::SmaccStateInfo::getStateLevel ( )

Definition at line 55 of file smacc_state_info.cpp.

56{
57 if (this->children_.size() == 0)
58 {
59 if (!this->parentState_.expired())
60 {
62 }
63 else
64 {
66 }
67 }
68 else
69 {
71 }
72}
std::vector< std::shared_ptr< SmaccStateInfo > > children_

References children_, parentState_, smacc2::introspection::STATE, smacc2::introspection::SUPERSTATE, and smacc2::introspection::SUPERSTATE_ROUTINE.

◆ getStateMachineInfo()

std::shared_ptr< SmaccStateMachineInfo > smacc2::introspection::SmaccStateInfo::getStateMachineInfo ( ) const
inline

Definition at line 221 of file smacc_state_info.hpp.

222 {
223 return stateMachine_.lock();
224 }

References stateMachine_.

Referenced by createChildState().

Here is the caller graph for this function:

◆ toShortName()

const std::string & smacc2::SmaccStateInfo::toShortName ( ) const

Definition at line 95 of file smacc_state_info.cpp.

95{ return this->demangledStateName; }

References demangledStateName.

Referenced by getFullPath().

Here is the caller graph for this function:

Member Data Documentation

◆ children_

std::vector<std::shared_ptr<SmaccStateInfo> > smacc2::introspection::SmaccStateInfo::children_

Definition at line 209 of file smacc_state_info.hpp.

Referenced by getStateLevel().

◆ demangledStateName

std::string smacc2::introspection::SmaccStateInfo::demangledStateName

Definition at line 201 of file smacc_state_info.hpp.

Referenced by getNode(), and toShortName().

◆ depth_

int smacc2::introspection::SmaccStateInfo::depth_ = 0

Definition at line 210 of file smacc_state_info.hpp.

Referenced by depth(), and SmaccStateInfo().

◆ eventGeneratorsInfo

◆ fullStateName

std::string smacc2::introspection::SmaccStateInfo::fullStateName

Definition at line 200 of file smacc_state_info.hpp.

Referenced by getDemangledFullName().

◆ parentState_

std::weak_ptr<SmaccStateInfo> smacc2::introspection::SmaccStateInfo::parentState_

Definition at line 206 of file smacc_state_info.hpp.

Referenced by getAncestors(), getFullPath(), getParentState(), and getStateLevel().

◆ stateIndex_

int smacc2::introspection::SmaccStateInfo::stateIndex_ = 0

Definition at line 199 of file smacc_state_info.hpp.

◆ stateMachine_

std::weak_ptr<SmaccStateMachineInfo> smacc2::introspection::SmaccStateInfo::stateMachine_

Definition at line 205 of file smacc_state_info.hpp.

Referenced by getNode(), and getStateMachineInfo().

◆ stateReactorsInfo

◆ staticBehaviorInfo

◆ tid_

const std::type_info* smacc2::introspection::SmaccStateInfo::tid_

Definition at line 211 of file smacc_state_info.hpp.

◆ transitions_

std::vector<SmaccTransitionInfo> smacc2::introspection::SmaccStateInfo::transitions_

Definition at line 207 of file smacc_state_info.hpp.

Referenced by declareTransition().


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