SMACC
Loading...
Searching...
No Matches
smacc_state_info.h
Go to the documentation of this file.
1/*****************************************************************************************************************
2 * ReelRobotix Inc. - Software License Agreement Copyright (c) 2018
3 * Authors: Pablo Inigo Blasco, Brett Aldrich
4 *
5 ******************************************************************************************************************/
6
7#pragma once
8#include <memory>
9#include <functional>
10#include <vector>
11#include <smacc/smacc_types.h>
12
13namespace smacc
14{
15namespace introspection
16{
17
19{
20 std::function<void(smacc::ISmaccState *)> factoryFunction;
21 const std::type_info *behaviorType;
22 const std::type_info *orthogonalType;
23};
24
25//---------------------------------------------
27{
28 SmaccEventInfo(std::shared_ptr<TypeInfo> eventType);
29
30 std::string getEventTypeName();
31
32 std::string getEventSourceName();
33
34 // AKA orthogonal
35 std::string getOrthogonalName();
36
37 std::string label;
38
39 std::shared_ptr<TypeInfo> eventType;
40
41private:
42};
43
45{
47 {
48 }
49
51 int index;
52 std::shared_ptr<SmaccStateInfo> sourceState;
53 std::shared_ptr<SmaccStateInfo> destinyState;
54
55 std::string transitionTag;
56 std::string transitionType;
57 std::shared_ptr<SmaccEventInfo> eventInfo;
58
60};
61//---------------------------------------------
62
64{
65 std::function<void(std::shared_ptr<smacc::StateReactor>)> fn;
66};
67
69{
70private:
71 std::vector<StateReactorCallbackFunctor> callbacks_;
72
73public:
74 void configureStateReactor(std::shared_ptr<smacc::StateReactor> sr);
75
76 template <typename TEv>
77 void addInputEvent();
78
79 template <typename TEv>
80 void setOutputEvent();
81
82 std::shared_ptr<smacc::introspection::SmaccStateReactorInfo> srInfo_;
83};
84
86{
87 std::shared_ptr<SmaccStateInfo> ownerState;
88 std::function<void(smacc::ISmaccState *)> factoryFunction;
89
90 const std::type_info *stateReactorType;
91 std::shared_ptr<TypeInfo> objectTagType;
92 std::vector<std::shared_ptr<SmaccEventInfo>> sourceEventTypes;
93 std::shared_ptr<StateReactorHandler> srh;
94};
95
96//---------------------------------------------------------
98{
99 std::function<void(std::shared_ptr<smacc::SmaccEventGenerator>)> fn;
100};
101
103{
104private:
105 std::vector<EventGeneratorCallbackFunctor> callbacks_;
106
107public:
108 void configureEventGenerator(std::shared_ptr<smacc::SmaccEventGenerator> eg);
109
110 template <typename TEv>
112
113 std::shared_ptr<smacc::introspection::SmaccEventGeneratorInfo> egInfo_;
114};
115
117{
118 std::shared_ptr<SmaccStateInfo> ownerState;
119 std::function<void(smacc::ISmaccState *)> factoryFunction;
120
121 const std::type_info *eventGeneratorType;
122 std::shared_ptr<TypeInfo> objectTagType;
123 std::vector<std::shared_ptr<SmaccEventInfo>> sourceEventTypes;
124 std::shared_ptr<EventGeneratorHandler> egh;
125};
126
127//---------------------------------------------
128
130{
131 SUPERSTATE = 2,
132 STATE = 1,
134};
135
136class SmaccStateInfo : public std::enable_shared_from_this<SmaccStateInfo>
137{
138
139public:
140 typedef std::shared_ptr<SmaccStateInfo> Ptr;
141
142 static std::map<const std::type_info *, std::vector<ClientBehaviorInfoEntry>> staticBehaviorInfo;
143 static std::map<const std::type_info *, std::vector<std::shared_ptr<SmaccStateReactorInfo>>> stateReactorsInfo;
144 static std::map<const std::type_info *, std::vector<std::shared_ptr<SmaccEventGeneratorInfo>>> eventGeneratorsInfo;
145
147 std::string fullStateName;
149
150 std::shared_ptr<SmaccStateMachineInfo> stateMachine_;
151 std::shared_ptr<SmaccStateInfo> parentState_;
152 std::vector<SmaccTransitionInfo> transitions_;
153
154 std::vector<std::shared_ptr<SmaccStateInfo>> children_;
156 const std::type_info *tid_;
157
158 SmaccStateInfo(const std::type_info *tid, std::shared_ptr<SmaccStateInfo> parentState, std::shared_ptr<SmaccStateMachineInfo> stateMachineInfo);
159
161
162 inline int depth() const { return depth_; }
163
164 void getAncestors(std::list<const SmaccStateInfo *> &ancestorsList) const;
165
166 std::string getFullPath();
167
168 template <typename StateType>
169 std::shared_ptr<SmaccStateInfo> createChildState();
170
171 template <typename EvType>
172 void declareTransition(std::shared_ptr<SmaccStateInfo> &dstState, std::string transitionTag, std::string transitionType, bool history, TypeInfo::Ptr transitionTypeInfo);
173
174 // template <typename EvSource, template <typename> typename EvType>
175 // void declareTransition(std::shared_ptr<SmaccStateInfo> &dstState, std::string transitionTag, std::string transitionType, bool history);
176
177 const std::string &toShortName() const;
178
179 std::string getDemangledFullName() const;
180};
181} // namespace introspection
182} // namespace smacc
void configureEventGenerator(std::shared_ptr< smacc::SmaccEventGenerator > eg)
std::shared_ptr< smacc::introspection::SmaccEventGeneratorInfo > egInfo_
std::vector< EventGeneratorCallbackFunctor > callbacks_
std::shared_ptr< SmaccStateInfo > createChildState()
void getAncestors(std::list< const SmaccStateInfo * > &ancestorsList) const
std::shared_ptr< SmaccStateInfo > Ptr
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
void declareTransition(std::shared_ptr< SmaccStateInfo > &dstState, std::string transitionTag, std::string transitionType, bool history, TypeInfo::Ptr transitionTypeInfo)
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::vector< SmaccTransitionInfo > transitions_
std::shared_ptr< SmaccStateInfo > parentState_
std::vector< StateReactorCallbackFunctor > callbacks_
std::shared_ptr< smacc::introspection::SmaccStateReactorInfo > srInfo_
void configureStateReactor(std::shared_ptr< smacc::StateReactor > sr)
std::shared_ptr< TypeInfo > Ptr
std::function< void(smacc::ISmaccState *)> factoryFunction
std::function< void(std::shared_ptr< smacc::SmaccEventGenerator >)> fn
std::function< void(smacc::ISmaccState *)> factoryFunction
std::vector< std::shared_ptr< SmaccEventInfo > > sourceEventTypes
std::shared_ptr< SmaccStateInfo > ownerState
std::shared_ptr< EventGeneratorHandler > egh
std::shared_ptr< TypeInfo > eventType
std::function< void(smacc::ISmaccState *)> factoryFunction
std::shared_ptr< StateReactorHandler > srh
std::vector< std::shared_ptr< SmaccEventInfo > > sourceEventTypes
std::shared_ptr< SmaccStateInfo > ownerState
std::shared_ptr< TypeInfo > objectTagType
std::shared_ptr< SmaccStateInfo > destinyState
std::shared_ptr< SmaccEventInfo > eventInfo
smacc::introspection::TypeInfo::Ptr transitionTypeInfo
std::shared_ptr< SmaccStateInfo > sourceState
std::function< void(std::shared_ptr< smacc::StateReactor >)> fn