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_HMI_CWORD77_Controller
21 ////////////////////////////////////////////////////////////////////////////////
24 * @file frameworkunified__CWORD77__session_if.h
25 * @brief \~english This file provides API for operating session
28 /** @addtogroup BaseSystem
31 /** @addtogroup native_service
35 /** @addtogroup framework_unified
36 * @ingroup native_service
39 /** @addtogroup _CWORD77_
40 * @ingroup framework_unified
43 #ifndef _FRAMEWORKUNIFIED__CWORD77_SESSION_H_ // NOLINT (build/header_guard)
44 #define _FRAMEWORKUNIFIED__CWORD77_SESSION_H_
46 #include <native_service/ns__CWORD77__common.h>
50 class CFrameworkunified_CWORD77_Session {
52 HANDLE m_hSession; ///< Handle to session
53 HANDLE m_hApp; ///< Handle to Framework
54 HANDLE m_hService; ///< Handle to Service
55 UI_32 m_uiSessionType; ///< Session Type
56 ResponseServiceTo_CWORD77_ m_ResponseTo_CWORD77_; ///< Call back function pointer
57 std::vector<FrameworkunifiedProtocolCallbackHandler> m_vSessionProtocolHanlder;
58 std::vector<UI_32> m_vEventVector;
59 std::vector<FrameworkunifiedProtocolCallbackHandler> m_vSessionEventHandler;
60 ////////////////////////////////////////////////////////////////////////////////////////////
62 /// Function to add notification
64 /// \param[in] f_uiCmdId
65 /// UI_32 - Command id
66 /// \param[in] f_cbFuncPtr
67 /// CbFuncPtr - Callback function pointer
70 ////////////////////////////////////////////////////////////////////////////////////////////
71 void AddProtocolHandler(UI_32 f_uiCmdId, CbFuncPtr f_cbFuncPtr);
72 ////////////////////////////////////////////////////////////////////////////////////////////
73 /// AttachProtocolwithDispatcher
74 /// API to Register Session 1 of Service A protocols with Dispatcher
76 /// \param [in] f_hApp
77 /// HANDLE - Handle to the Framework
79 /// EFrameworkunifiedStatus - Success or Error
80 ////////////////////////////////////////////////////////////////////////////////////////////
81 EFrameworkunifiedStatus AttachProtocolwithDispatcher(HANDLE f_hApp);
82 ////////////////////////////////////////////////////////////////////////////////////////////
83 /// DetachProtocolwithDispatcher
84 /// API to Un Register Session 1 of Service A protocols with Dispatcher
86 /// \param [in] f_hApp
87 /// HANDLE - Handle to the Framework
89 /// EFrameworkunifiedStatus - Success or Error
90 ////////////////////////////////////////////////////////////////////////////////////////////
91 EFrameworkunifiedStatus DetachProtocolwithDispatcher(HANDLE f_hApp);
92 ////////////////////////////////////////////////////////////////////////////////////////////
93 /// AttachEventswithDispatcher
94 /// Function to register events with dispatcher
96 /// \param [in] f_hApp
97 /// HANDLE - Handle to the Framework
99 /// EFrameworkunifiedStatus - Success or Error
100 ////////////////////////////////////////////////////////////////////////////////////////////
101 EFrameworkunifiedStatus AttachEventswithDispatcher(HANDLE f_hApp);
102 ////////////////////////////////////////////////////////////////////////////////////////////
104 /// Function to register events
106 /// \param [in] f_hApp
107 /// HANDLE - Handle to the Framework
109 /// EFrameworkunifiedStatus - Success or Error
110 ////////////////////////////////////////////////////////////////////////////////////////////
111 EFrameworkunifiedStatus RegisterEvents(HANDLE f_hApp); // Function: added by Shyam to overcome
112 /// the naming conflict in registering the event
114 ////////////////////////////////////////////////////////////////////////////////////////////
115 /// AttachEventHandlerswithDispatcher
116 /// API to Register Session 1 of Service A protocols with Dispatcher
118 /// \param [in] f_hApp
119 /// HANDLE - Handle to the Framework
121 /// EFrameworkunifiedStatus - Success or Error
122 ////////////////////////////////////////////////////////////////////////////////////////////
123 EFrameworkunifiedStatus AttachEventHandlerswithDispatcher(HANDLE f_hApp);
124 ////////////////////////////////////////////////////////////////////////////////////////////
125 /// DetachEventHandlerswithDispatcher
126 /// API to Un Register Session 1 of Service A protocols with Dispatcher
128 /// \param [in] f_hApp
129 /// HANDLE - Handle to the Framework
131 /// EFrameworkunifiedStatus - Success or Error
132 ////////////////////////////////////////////////////////////////////////////////////////////
133 EFrameworkunifiedStatus DetachEventHandlerswithDispatcher(HANDLE f_hApp);
134 ////////////////////////////////////////////////////////////////////////////////////////////
136 /// Function to add event handler
138 /// \param[in] f_uiCmdId
139 /// UI_32 - Command id
140 /// \param[in] f_cbFuncPtr
141 /// CbFuncPtr - Callback function pointer
144 ////////////////////////////////////////////////////////////////////////////////////////////
145 void AddEventHandler(UI_32 f_uiCmdId, CbFuncPtr f_cbFuncPtr);
148 ////////////////////////////////////////////////////////////////////////////////////////////
149 /// \ingroup CFrameworkunified_CWORD77_Session
150 /// \~english @par Brief
151 /// Constructor for CFrameworkunified_CWORD77_Session
152 /// \~english @retval none
153 /// \~english @par Preconditons
155 /// \~english @par Change of internal status
157 /// \~english @par Conditions of processing failure
159 /// \~english @par Detail
160 /// Create CFrameworkunified_CWORD77_Session instance and initialize the member parameter(m_hSession, m_hApp,m_hService,\n
162 /// \~english @par Classification
164 /// \~english @par Type
166 /// \~english @see ~CFrameworkunified_CWORD77_Session
167 ////////////////////////////////////////////////////////////////////////////////////////////
168 CFrameworkunified_CWORD77_Session();
170 ////////////////////////////////////////////////////////////////////////////////////////////
171 /// \ingroup CFrameworkunified_CWORD77_Session
172 /// \~english @par Brief
173 /// Destructor for CFrameworkunified_CWORD77_Session
174 /// \~english @retval none
175 /// \~english @par Preconditons
176 /// CFrameworkunified_CWORD77_Session is decleared in constructor
177 /// \~english @par Change of internal status
179 /// \~english @par Conditions of processing failure
181 /// \~english @par Detail
182 /// Release CFrameworkunified_CWORD77_Session class instance
183 /// \~english @par Classification
185 /// \~english @par Type
187 /// \~english @see CFrameworkunified_CWORD77_Session
188 ////////////////////////////////////////////////////////////////////////////////////////////
189 virtual ~CFrameworkunified_CWORD77_Session();
191 ////////////////////////////////////////////////////////////////////////////////////////////
192 /// \ingroup CFrameworkunified_CWORD77_Session
193 /// \~english @par Brief
194 /// send specific command by session
195 /// \~english @param [in] cmdID
196 /// cmdID - commond id
199 /// \~english @retval EFrameworkunifiedStatus
200 /// eFrameworkunifiedStatusOK or failed
201 /// \~english @par Preconditons
202 /// - no preconditions
203 /// \~english @par Change of internal status
205 /// \~english @par Conditions of processing failure
206 /// - GetReqDataFrom_CWORD77_DataPool() failed [eFrameworkunifiedStatusDbRecNotFound]
207 /// - FrameworkunifiedSendMsg() failed
208 /// - if m_hSession is NULL. [eFrameworkunifiedStatusSessionErr]
209 /// \~english @par Detail
210 /// send specified commond by session.
211 /// \~english @par Classification
213 /// \~english @par Type
215 /// \~english @see GetReqDataFrom_CWORD77_DataPool
216 ////////////////////////////////////////////////////////////////////////////////////////////
217 // virtual EFrameworkunifiedStatus HandleSessionMessage(UI_32 cmdID);
218 EFrameworkunifiedStatus HandleSessionMessage(UI_32 cmdID);
220 ////////////////////////////////////////////////////////////////////////////////////////////
221 /// \ingroup CFrameworkunified_CWORD77_Session
222 /// \~english @par Brief
223 /// Set Call back function in Session
224 /// \~english @param [in] fptr
225 /// fptr - Pointer to call back function
227 /// fptr ResponseServiceTo_CWORD77_*
228 /// \~english @retval none
229 /// \~english @par Preconditons
230 /// - no preconditions
231 /// \~english @par Change of internal status
232 /// - set callback into m_ResponseTo_CWORD77_.
233 /// \~english @par Conditions of processing failure
235 /// \~english @par Detail
236 /// Set Call back function in Session
237 /// \~english @par Classification
239 /// \~english @par Type
242 ////////////////////////////////////////////////////////////////////////////////////////////
243 void SetResponseCallback(ResponseServiceTo_CWORD77_ fptr);
245 ////////////////////////////////////////////////////////////////////////////////////////////
246 /// \ingroup CFrameworkunified_CWORD77_Session
247 /// \~english @par Brief
248 /// function to Open Session.(pure virtual function)
249 /// \~english @param [in] f_hApp
250 /// f_hApp - Handle of framework
253 /// \~english @param [in] f_sServiceName
254 /// f_sServiceName - Service Name
256 /// f_sServiceName std::string
257 /// \~english @retval EFrameworkunifiedStatus
259 /// \~english @par Preconditons
260 /// - no preconditions
261 /// \~english @par Change of internal status
263 /// \~english @par Conditions of processing failure
265 /// \~english @par Detail
266 /// \~english @par Classification
268 /// \~english @par Type
271 ////////////////////////////////////////////////////////////////////////////////////////////
272 virtual EFrameworkunifiedStatus OpenSession(HANDLE f_hApp, std::string f_sServiceName) = 0;
274 ////////////////////////////////////////////////////////////////////////////////////////////
275 /// \ingroup CFrameworkunified_CWORD77_Session
276 /// \~english @par Brief
277 /// function to close Session.(pure virtual function)
278 /// \~english @param [in] f_hApp
279 /// f_hApp - Handle of framework
282 /// \~english @retval EFrameworkunifiedStatus
284 /// \~english @par Preconditons
285 /// - no preconditions
286 /// \~english @par Change of internal status
288 /// \~english @par Conditions of processing failure
290 /// \~english @par Detail
292 /// \~english @par Classification
294 /// \~english @par Type
297 ////////////////////////////////////////////////////////////////////////////////////////////
298 virtual EFrameworkunifiedStatus CloseSession(HANDLE f_hApp) = 0;
300 ////////////////////////////////////////////////////////////////////////////////////////////
301 /// \ingroup CFrameworkunified_CWORD77_Session
302 /// \~english @par Brief
303 /// Open Session acknowledge.(pure virtual function)
304 /// \~english @param [in] f_hApp
305 /// f_hApp - Handle of framework
308 /// \~english @retval EFrameworkunifiedStatus
310 /// \~english @par Preconditons
311 /// - no preconditions
312 /// \~english @par Change of internal status
314 /// \~english @par Conditions of processing failure
316 /// \~english @par Detail
318 /// \~english @par Classification
320 /// \~english @par Type
323 ////////////////////////////////////////////////////////////////////////////////////////////
324 virtual EFrameworkunifiedStatus OpenSessionAcknowledge(HANDLE f_hApp) = 0;
325 ////////////////////////////////////////////////////////////////////////////////////////////
327 /// API to get session type
329 /// \return UI_32 - Session type
330 /// EFrameworkunifiedStatus - Success or Error
331 ////////////////////////////////////////////////////////////////////////////////////////////
333 ////////////////////////////////////////////////////////////////////////////////////////////
334 /// \ingroup CFrameworkunified_CWORD77_Session
335 /// \~english @par Brief
336 /// API to get session type
337 /// \~english @param none
338 /// \~english @retval UI_32 - Session type
339 /// \~english @par Preconditons
340 /// - no preconditions
341 /// \~english @par Change of internal status
343 /// \~english @par Conditions of processing failure
345 /// \~english @par Detail
346 /// API to get session type.\n
347 /// \~english @par Classification
349 /// \~english @par Type
352 ////////////////////////////////////////////////////////////////////////////////////////////
353 UI_32 GetSessionType();
355 ////////////////////////////////////////////////////////////////////////////////////////////
356 /// \ingroup CFrameworkunified_CWORD77_Session
357 /// \~english @par Brief
358 /// API to set session type into class CFrameworkunified_CWORD77_Session object.
359 /// \~english @param[in] sessioType
360 /// const UI_32& - Session type
361 /// \~english @retval none
362 /// \~english @par Preconditons
364 /// \~english @par Change of internal status
366 /// \~english @par Conditions of processing failure
368 /// \~english @par Detail
369 /// API to set session type into class CFrameworkunified_CWORD77_Session object.
370 /// \~english @par Classification
372 /// \~english @par Type
376 ////////////////////////////////////////////////////////////////////////////////////////////
377 void SetSessionType(const UI_32 &sessioType);
379 ////////////////////////////////////////////////////////////////////////////////////////////
380 /// \ingroup CFrameworkunified_CWORD77_Session
381 /// \~english @par Brief
382 /// declear callback funcion into Dispatcher
383 /// \~english @param[in] hApp
384 /// HANDLE - Handle to Application
385 /// \~english @retval none
386 /// \~english @par Preconditons
388 /// \~english @par Change of internal status
390 /// \~english @par Conditions of processing failure
392 /// \~english @par Detail
393 /// declear OnResponse() of callback function by calling FrameworkunifiedAttachCallbackToDispatcher()\n
394 /// get decleared protocol ID through GetResponseProtocolArray()\n
395 /// get decleared event ID through GetEventArray() and regist event-sending instance in FrameworkunifiedRegisterEvent
397 /// cautions in using this API:\n
398 /// -Registrition will fail without msg When Application handle is uncorrect set by parameter\n
399 /// -Registrition process in FrameworkunifiedAttachCallbackToDispatcher() will not commit when
400 /// GetResponseProtocolArray()\n
401 /// or GetEventArray() returns NULL or NULL list
402 /// \~english @par Classification
404 /// \~english @par Type
406 /// \~english @see FrameworkunifiedAttachCallbackToDispatcher, FrameworkunifiedRegisterEvent,
407 /// GetResponseProtocolArray, GetEventArray, OnResponse
408 ////////////////////////////////////////////////////////////////////////////////////////////
409 void AttachResponseCallbacks(HANDLE hApp);
411 ////////////////////////////////////////////////////////////////////////////////////////////
412 /// \ingroup CFrameworkunified_CWORD77_Session
413 /// \~english @par Brief
414 /// unscrible dispatcher callback function
415 /// \~english @param[in] hApp
416 /// HANDLE - Handle to Application
417 /// \~english @retval none
418 /// \~english @par Preconditons
420 /// \~english @par Change of internal status
422 /// \~english @par Conditions of processing failure
424 /// \~english @par Detail
425 /// declear OnResponse() of callback function by calling FrameworkunifiedDetachCallbackFromDispatcher()\n
426 /// get unregistrition protocol ID through GetResponseProtocolArray()\n
427 /// get unregistrition event ID through GetEventArray() and unregist event-sending instance in \n
428 /// FrameworkunifiedUnRegisterEvent()
429 /// \~english @par Detail
430 /// cautions in using this API:\n
431 /// -Unregistrition will fail without msg When Application handle is uncorrect set by parameter\n
432 /// -Unregistrition process in FrameworkunifiedDetachCallbackFromDispatcher() will not commit when
433 /// GetResponseProtocolArray()\n
434 /// or GetEventArray() returns NULL or NULL list
435 /// \~english @par Classification
437 /// \~english @par Type
439 /// \~english @see FrameworkunifiedDetachCallbackFromDispatcher, FrameworkunifiedUnRegisterEvent,
440 /// GetResponseProtocolArray, GetEventArray
441 ////////////////////////////////////////////////////////////////////////////////////////////
442 void DetachResponseCallbacks(HANDLE hApp);
444 ////////////////////////////////////////////////////////////////////////////////////////////
446 /// Callback function on receiving response protocol or event specified in the list, returned
447 /// by either \ref GetResponseProtocolArray or \ref GetEventArray
450 /// HANDLE - Handle to framework
452 ////////////////////////////////////////////////////////////////////////////////////////////
454 ////////////////////////////////////////////////////////////////////////////////////////////
455 /// \ingroup CFrameworkunified_CWORD77_Session
456 /// \~english @par Brief
457 /// Callback function on receiving response protocol or event specified in the list, returned
458 /// by either \ref GetResponseProtocolArray or \ref GetEventArray
459 /// \~english @param [in] f_hApp
460 /// HANDLE - Handle of framework
462 /// \~english @retval EFrameworkunifiedStatus
463 /// SuceFrameworkunifiedStatusOK or eFrameworkunifiedStatusNullPointer
464 /// \~english @par Preconditions
465 /// - no preconditions
466 /// \~english @par Change of internal status
467 /// - framework handler is invalid handler.[eFrameworkunifiedStatusNullPointer]
468 /// \~english @par Conditions of processing failure
470 /// \~english @par Detail
471 /// Callback function on receiving response protocol or event specified in the list, returned
472 /// by either \ref GetResponseProtocolArray or \ref GetEventArray
473 /// \~english @par Classification
475 /// \~english @par Type
477 /// \~english @see FrameworkunifiedGetMsgDataOfSize
478 ////////////////////////////////////////////////////////////////////////////////////////////
479 EFrameworkunifiedStatus OnResponse(HANDLE hApp);
481 // FIXME: Following set of functions should be pure virtual functions.
482 // But, in order to avoid build errors for HMI__CWORD77_, it is defined as virtual functions only.
483 // Because nobody who is currently deriving off of frameworkunified__CWORD77__session_if.h has these functions implemented.
484 virtual UI_32 const *GetResponseProtocolArray() = 0;
485 virtual UI_32 const GetResponseProtocolArrayLength() = 0;
486 virtual UI_32 const *GetEventArray() = 0;
487 virtual UI_32 const GetEventArrayLength() = 0;
490 #endif // _FRAMEWORKUNIFIED__CWORD77_SESSION_H_ NOLINT (build/header_guard)