Init basesystem source codes.
[staging/basesystem.git] / video_in_hal / nsframework / framework_unified / client / include / native_service / frameworkunified_sm_conditionconnector.h
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 ///////////////////////////////////////////////////////////////////////////////
18 /// \ingroup  tag_NSFramework
19 /// \brief
20 ///       This file has class declaration of the CFrameworkunifiedConditionConnector. This class is responsible for
21 ///     implementing interfaces required to use condition connector in statemachine.
22 ///
23 ///////////////////////////////////////////////////////////////////////////////
24 //@{
25 /**
26  * @file frameworkunified_sm_conditionconnector.h
27  * @brief \~english This file has class declaration of the CFrameworkunifiedConditionConnector. This class is responsible for
28  *        implementing interfaces required to use condition connector in statemachine.
29  *
30  */
31 /** @addtogroup BaseSystem
32  *  @{
33  */
34 /** @addtogroup native_service
35  *  @ingroup BaseSystem
36  *  @{
37  */
38 /** @addtogroup framework_unified
39  *  @ingroup native_service
40  *  @{
41  */
42 /** @addtogroup framework
43  *  @ingroup framework_unified
44  *  @{
45  */
46 /** @addtogroup statemachine
47  *  @ingroup framework
48  *  @{
49  */
50 #ifndef __FRAMEWORKUNIFIED_NATIVESERVICES_NSFRAMEWORKCORE_STATEMACHINE_INC_FRAMEWORKUNIFIEDSMCONDITIONCONNECTOR_H__  // NOLINT  (build/header_guard)
51 #define __FRAMEWORKUNIFIED_NATIVESERVICES_NSFRAMEWORKCORE_STATEMACHINE_INC_FRAMEWORKUNIFIEDSMCONDITIONCONNECTOR_H__
52
53 #include <native_service/frameworkunified_sm_externaltransition.h>
54 #include <string>
55 #include <vector>
56
57 // This class is responsible for  implementing interfaces required to use condition connector in statemachine.
58 class CFrameworkunifiedConditionConnector : public CFrameworkunifiedExternalTransition {
59  public:
60   ///////////////////////////////////////////////////////////////////////////////////////////
61   /// \ingroup CFrameworkunifiedConditionConnector
62   /// \~english @par Brief
63   ///          Constructor for class CFrameworkunifiedConditionConnector.
64   /// \~english @param [in] f_strName
65   ///     std::string - Name of the condition connector
66   /// \~english @retval
67   /// \~english @par Prerequisite
68   ///            none
69   /// \~english @par Change of internal state
70   ///            none
71   /// \~english @par Conditions of processing failure
72   ///            none
73   /// \~english @par Detail
74   ///           Inherite from base class CFrameworkunifiedExternalTransition.
75   /// \~english @par Classification
76   ///           public
77   /// \~english @par Type
78   ///           none
79   /// \~english @see CFrameworkunifiedExternalTransition, ~CFrameworkunifiedConditionConnector
80   ///////////////////////////////////////////////////////////////////////////////////////////
81   CFrameworkunifiedConditionConnector(std::string f_strName);  // NOLINT  (readability/nolint)
82
83   ///////////////////////////////////////////////////////////////////////////////////////////
84   /// \ingroup CFrameworkunifiedConditionConnector
85   /// \~english @par Brief
86   ///        Destructor for CFrameworkunifiedCompositeState
87   /// \~english @retval none
88   /// \~english @par Preconditons
89   ///          - Self instance of CFrameworkunifiedConditionConnector created.
90   /// \~english @par Change of internal status
91   ///                none
92   /// \~english @par Conditions of processing failure
93   ///                none
94   /// \~english @par Detail
95   ///          Class CFrameworkunifiedExternalTransition instance and CFrameworkunifiedConditionConnector instance release.
96   /// \~english @par Classification
97   ///           public
98   /// \~english @par Type
99   ///            none
100   /// \~english @see CFrameworkunifiedConditionConnector::CFrameworkunifiedConditionConnector
101   ///////////////////////////////////////////////////////////////////////////////////////////
102   virtual ~CFrameworkunifiedConditionConnector();
103
104   ////////////////////////////////////////////////////////////////////////////////////////////
105   /// \ingroup CFrameworkunifiedConditionConnector
106   /// \~english @par Brief
107   ///     This API evaluates the guards added in the condition list. If the guard is evaluated as
108   ///     true then statemachine transitions to target state associated with guard.
109   /// \~english @param [in] f_pSourceState
110   ///           CFrameworkunifiedState* - Source state in which reaction is being executed
111   /// \~english @param [in] f_pData
112   ///           CEventDataPtr - event data
113   /// \~english @retval CFrameworkunifiedState*
114   ///                   CFrameworkunifiedState* - Returns Active state
115   /// \~english @par Preconditons
116   ///        -  Self instance of CFrameworkunifiedConditionConnector created.
117   /// \~english @par Change of internal status
118   ///        -  none
119   /// \~english @par Conditions of processing failure
120   ///            - If parameter f_pSourceState is NULL. [NULL]
121   ///            - If m_pConditionList is NULL. [NULL]
122   /// \~english @par Detail
123   ///     This API evaluates the guards added in the condition list. If the guard is evaluated as
124   ///     true then statemachine transitions to target state associated with guard.
125   /// \~english @par Classification
126   ///          public
127   /// \~english @par Type
128   ///          none
129   /// \~english @see none
130   ////////////////////////////////////////////////////////////////////////////////////////////
131   virtual CFrameworkunifiedState *FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState, CEventDataPtr f_pData);
132
133   ////////////////////////////////////////////////////////////////////////////////////////////
134   /// \ingroup CFrameworkunifiedConditionConnector
135   /// \~english @par Brief
136   ///           Adds connect condition into condition list of current connection
137   /// \~english @param [in] f_pGuard
138   ///           CFrameworkunifiedState* - Pointer to the guard object to be added in the currrent connection
139   /// \~english @param [in] f_pTargetState
140   ///           CFrameworkunifiedState* - Target state for given guard condition
141   /// \~english @retval EFrameworkunifiedStatus   eFrameworkunifiedStatusOK
142   ///                                 eFrameworkunifiedStatusNullPointer
143   /// \~english @par Preconditons
144   ///        -  Self instance of CFrameworkunifiedConditionConnector created.
145   /// \~english @par Change of internal status
146   ///        -  none
147   /// \~english @par Conditions of processing failure
148   ///            - If m_pConditionList is NULL. [eFrameworkunifiedStatusNullPointer]
149   ///            - If parameter f_pGuard is NULL. [eFrameworkunifiedStatusNullPointer]
150   ///            - If parameter f_pTargetState is NULL. [eFrameworkunifiedStatusNullPointer]
151   /// \~english @par Detail
152   ///            Adds connect condition into condition list of current connection.\n
153   /// \~english @par Classification
154   ///          public
155   /// \~english @par Type
156   ///          none
157   /// \~english @see none
158   ////////////////////////////////////////////////////////////////////////////////////////////
159   virtual EFrameworkunifiedStatus FrameworkunifiedAddCondition(CFrameworkunifiedGuard *f_pGuard, CFrameworkunifiedState *f_pTargetState);
160
161  private:
162   // This class defines the conditions required in condition connector
163   class CCondition {
164    public:
165     ///////////////////////////////////////////////////////////////////////////////////////////
166     /// CCondition
167     /// Parameterized constructor
168     /// \param [in] f_pGuard
169     ///     CFrameworkunifiedGuard* - guard object
170     /// \param [in] f_pTargetState
171     ///     CFrameworkunifiedState* - target state for a condition
172     ///
173     /// \return none
174     ///////////////////////////////////////////////////////////////////////////////////////////
175     CCondition(CFrameworkunifiedGuard *f_pGuard, CFrameworkunifiedState *f_pTargetState);
176
177     // pointer to guard that will be evaluated for a condition
178     CFrameworkunifiedGuard *m_pGuard;
179
180     // pointer to target state for a condition
181     CFrameworkunifiedState *m_pTargetState;
182   };
183
184   // Condition list
185   typedef std::vector<CCondition *> TConditionList;
186
187   // Condition list iterator
188   typedef TConditionList::iterator TConditionIterator;
189
190   // condition connector name
191   std::string m_strName;
192
193   // List of conditions
194   TConditionList *m_pConditionList;
195 };
196
197 #endif /* __FRAMEWORKUNIFIED_NATIVESERVICES_NSFRAMEWORKCORE_STATEMACHINE_INC_FRAMEWORKUNIFIEDSMCONDITIONCONNECTOR_H__ */  // NOLINT  (build/header_guard)
198 /** @}*/
199 /** @}*/
200 /** @}*/
201 /** @}*/
202 /** @}*/
203 //@}