2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 ///////////////////////////////////////////////////////////////////////////////////////////////////
18 /// \ingroup tag_StateMachine
21 /// This File has public Macro definition that simplifies the statemachine implementation
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 #ifndef FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_STATEMACHINE_FRAMEWORKUNIFIED_SM_FRAMEWORK_CORE_H_
26 #define FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_STATEMACHINE_FRAMEWORKUNIFIED_SM_FRAMEWORK_CORE_H_
28 #include <native_service/frameworkunified_framework_types.h>
32 /// connect child state to parent state and sets it as default state
33 #define CONNECT_DEFAULTSTATE(parent, child) \
34 FrameworkunifiedConnect(l_p## parent, l_p## child, TRUE);
36 /// connect child state to parent state
37 #define CONNECT_STATE(parent, child) \
38 FrameworkunifiedConnect(l_p## parent, l_p## child);
40 /// connect the deferred event and reactions and associate them with the state
41 #define CONNECT_DEFERREDEVENT(state, eventid) \
42 FrameworkunifiedConnect(l_p## state, _## eventid, NULL, #eventid, TRUE); \
44 /// connect the event and reactions and associate them with the state
45 #define CONNECT_EVENT(state, eventid, reaction) \
46 FrameworkunifiedConnect(l_p## state, _## eventid, l_pTrn## reaction, #eventid);
48 /// connect the event and reactions and associate them with the state
49 #define CONNECT_LOCAL_EVENT(state, eventid, reaction) \
50 FrameworkunifiedConnect(l_p## state, _## eventid, l_pLocalTrn## reaction, #eventid);
52 /// Sets the state as root state in the statemachine
53 #define CONNECTROOT(state) \
54 FrameworkunifiedConnect(l_p## state);
57 #define CREATE_STATE(class_name) \
58 CHKNULL(m_pFrameworkunifiedStateList) \
59 C## class_name *l_p## class_name = new C## class_name(#class_name); \
60 CHKNULL(l_p## class_name) \
61 m_pFrameworkunifiedStateList->insert(std::pair<UI_32, CFrameworkunifiedState*>(e## class_name, l_p## class_name));
63 // create a new shallow history state and add it in parent state
64 #define ADD_SHALLOWHISTORYSTATE(parent) \
65 CFrameworkunifiedShallowHistoryState *l_p##parent##SHALLOWHISTORYSTATE = new CFrameworkunifiedShallowHistoryState(SHALLOWHISTORYSTATE);\
66 FrameworkunifiedConnect(l_p## parent, l_p##parent##SHALLOWHISTORYSTATE);\
67 l_p##parent##SHALLOWHISTORYSTATE->SetDefaultHistory();
69 // create a new shallow history state and add it in parent state
70 #define ADD_DEEPHISTORYSTATE(parent) \
71 CFrameworkunifiedDeepHistoryState *l_p##parent##DEEPHISTORYSTATE = new CFrameworkunifiedDeepHistoryState(DEEPHISTORYSTATE);\
72 FrameworkunifiedConnect(l_p## parent, l_p##parent##DEEPHISTORYSTATE);\
73 l_p##parent##DEEPHISTORYSTATE->SetDefaultHistory();
75 /// connect deep history event to reaction and add to state
76 #define CONNECT_DEEPHISTORYEVENT(state, eventid, reaction) \
77 FrameworkunifiedConnect(l_p## state, _## eventid, l_pTrn##reaction##DEEPHISTORYSTATE, #eventid);
79 /// connect shallow history event to reaction and add to state
80 #define CONNECT_SHALLOWHISTORYEVENT(state, eventid, reaction) \
81 FrameworkunifiedConnect(l_p## state, _## eventid, l_pTrn##reaction##SHALLOWHISTORYSTATE, #eventid);
83 typedef struct _HSMConfigOptions {
84 EUserChangeOptions eUserChange;
85 BOOL bAutoPublishServiceAvaialble;
86 BOOL bWaitInStoppingState;
89 #endif // FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_STATEMACHINE_FRAMEWORKUNIFIED_SM_FRAMEWORK_CORE_H_