SMACC
Loading...
Searching...
No Matches
smacc_state_info.cpp
Go to the documentation of this file.
2#include <ros/ros.h>
3#include <smacc/common.h>
4
5namespace smacc
6{
7using namespace smacc::introspection;
8
9std::map<const std::type_info *, std::vector<ClientBehaviorInfoEntry>> SmaccStateInfo::staticBehaviorInfo;
10std::map<const std::type_info *, std::vector<std::shared_ptr<smacc::introspection::SmaccStateReactorInfo>>> SmaccStateInfo::stateReactorsInfo;
11std::map<const std::type_info *, std::vector<std::shared_ptr<SmaccEventGeneratorInfo>>> SmaccStateInfo::eventGeneratorsInfo;
12
13SmaccStateInfo::SmaccStateInfo(const std::type_info *tid, std::shared_ptr<SmaccStateInfo> parentState, std::shared_ptr<SmaccStateMachineInfo> stateMachineInfo)
14{
15 tid_ = tid;
16 parentState_ = parentState;
17 stateMachine_ = stateMachineInfo;
18
19 if (parentState_ != nullptr)
20 depth_ = parentState->depth_ + 1;
21}
22
23void SmaccStateInfo::getAncestors(std::list<const SmaccStateInfo*> &ancestorsList) const
24{
25 ancestorsList.push_front(this);
26 if (parentState_ != nullptr)
27 {
28 this->parentState_->getAncestors(ancestorsList);
29 }
30}
31
33{
34 if (this->children_.size() == 0)
35 {
36 if (this->parentState_ != nullptr)
37 {
39 }
40 else
41 {
43 }
44 }
45 else
46 {
48 }
49}
50
52{
53 if (parentState_ == nullptr)
54 return this->toShortName();
55 else
56 return this->parentState_->getFullPath() + "/" + this->toShortName();
57}
58
59const std::string &SmaccStateInfo::toShortName() const
60{
61 return this->demangledStateName;
62}
63
65{
66 return demangleSymbol(this->fullStateName.c_str());
67}
68//---------------------------------------------
69SmaccEventInfo::SmaccEventInfo(std::shared_ptr<TypeInfo> eventType)
70{
71 ROS_INFO_STREAM("CREATING EVENT INFO: " << eventType->getFullName());
72
73 this->eventType = eventType;
74}
75
77{
78 if (eventType->templateParameters.size() > 0)
79 {
80 auto eventsourcename = demangleSymbol(eventType->templateParameters[0]->getFullName().c_str());
81 return eventsourcename;
82 }
83 else
84 {
85 return "";
86 }
87}
88
90{
91 return demangleSymbol(eventType->getNonTemplatedTypeName().c_str());
92}
93
95{
96 if (eventType->templateParameters.size() > 1)
97 {
98 return demangleSymbol(eventType->templateParameters[1]->getFullName().c_str());
99 }
100 else
101 {
102 return "";
103 }
104}
105
106} // namespace smacc
SmaccStateInfo(const std::type_info *tid, std::shared_ptr< SmaccStateInfo > parentState, std::shared_ptr< SmaccStateMachineInfo > stateMachineInfo)
void getAncestors(std::list< const SmaccStateInfo * > &ancestorsList) const
const std::string & toShortName() const
std::vector< std::shared_ptr< SmaccStateInfo > > children_
std::shared_ptr< SmaccStateMachineInfo > stateMachine_
static std::map< const std::type_info *, std::vector< std::shared_ptr< SmaccStateReactorInfo > > > stateReactorsInfo
static std::map< const std::type_info *, std::vector< ClientBehaviorInfoEntry > > staticBehaviorInfo
static std::map< const std::type_info *, std::vector< std::shared_ptr< SmaccEventGeneratorInfo > > > eventGeneratorsInfo
std::shared_ptr< SmaccStateInfo > parentState_
std::string demangleSymbol()
Definition: introspection.h:75
SmaccEventInfo(std::shared_ptr< TypeInfo > eventType)
std::shared_ptr< TypeInfo > eventType