SMACC
Loading...
Searching...
No Matches
orthogonal.cpp
Go to the documentation of this file.
4
5namespace smacc
6{
8 {
9 this->stateMachine_ = value;
10 this->onInitialize();
11 }
12
13 void ISmaccOrthogonal::addClientBehavior(std::shared_ptr<smacc::ISmaccClientBehavior> clBehavior)
14 {
15 if (clBehavior != nullptr)
16 {
17 ROS_INFO("[Orthogonal %s] adding client behavior: %s", this->getName().c_str(), clBehavior->getName().c_str());
18 clBehavior->stateMachine_ = this->getStateMachine();
19 clBehavior->currentOrthogonal = this;
20
21 clientBehaviors_.back().push_back(clBehavior);
22 }
23 else
24 {
25 ROS_INFO("[orthogonal %s] no client behaviors in this state", this->getName().c_str());
26 }
27 }
28
30 {
31 }
32
34 {
35 ROS_INFO("[Orthogonal %s] initState: %s", this->getName().c_str(), state->getClassName().c_str());
36 clientBehaviors_.push_back(std::vector<std::shared_ptr<smacc::ISmaccClientBehavior>>());
37 }
38
39 std::string ISmaccOrthogonal::getName() const
40 {
41 return demangleSymbol(typeid(*this).name());
42 }
43
45 {
46 for (auto &clBehavior : clientBehaviors_.back())
47 {
48 ROS_INFO("[Orthogonal %s] runtimeConfigure, current Behavior: %s", this->getName().c_str(),
49 clBehavior->getName().c_str());
50
51 clBehavior->runtimeConfigure();
52 }
53 }
54
56 {
57 if (clientBehaviors_.back().size() > 0)
58 {
59 for (auto &clBehavior : clientBehaviors_.back())
60 {
61 ROS_INFO("[Orthogonal %s] OnEntry, current Behavior: %s", this->getName().c_str(), clBehavior->getName().c_str());
62
63 try
64 {
65 clBehavior->executeOnEntry();
66 }
67 catch (const std::exception &e)
68 {
69 ROS_ERROR("[ClientBehavior %s] Exception on Entry - continuing with next client behavior. Exception info: %s",
70 clBehavior->getName().c_str(), e.what());
71 }
72 }
73 }
74 else
75 {
76 ROS_INFO("[Orthogonal %s] OnEntry", this->getName().c_str());
77 }
78 }
79
81 {
82 if (clientBehaviors_.back().size() > 0)
83 {
84 for (auto &clBehavior : clientBehaviors_.back())
85 {
86 ROS_INFO("[Orthogonal %s] OnExit, current Behavior: %s", this->getName().c_str(), clBehavior->getName().c_str());
87 try
88 {
89 clBehavior->executeOnExit();
90 }
91 catch (const std::exception &e)
92 {
93 ROS_ERROR("[ClientBehavior %s] Exception onExit - continuing with next client behavior. Exception info: %s", clBehavior->getName().c_str(), e.what());
94 }
95 }
96 }
97 else
98 {
99 ROS_INFO("[Orthogonal %s] OnExit", this->getName().c_str());
100 }
101 }
102
104 {
105 for (auto &clBehavior : clientBehaviors_.back())
106 {
107 clBehavior->dispose();
108 this->getStateMachine()->disconnectSmaccSignalObject((void*)clBehavior.get());
109 }
110
111 clientBehaviors_.back().clear();
112 clientBehaviors_.pop_back();
113 }
114} // namespace smacc
void setStateMachine(ISmaccStateMachine *value)
Definition: orthogonal.cpp:7
ISmaccStateMachine * stateMachine_
virtual std::string getName() const
Definition: orthogonal.cpp:39
virtual void onInitialize()
Definition: orthogonal.cpp:29
void initState(ISmaccState *state)
Definition: orthogonal.cpp:33
std::vector< std::vector< std::shared_ptr< smacc::ISmaccClientBehavior > > > clientBehaviors_
ISmaccStateMachine * getStateMachine()
void addClientBehavior(std::shared_ptr< smacc::ISmaccClientBehavior > clientBehavior)
Definition: orthogonal.cpp:13
void disconnectSmaccSignalObject(void *object)
virtual std::string getClassName()
Definition: smacc_state.cpp:6
std::string demangleSymbol()
Definition: introspection.h:75