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__service_if.h
25 * @brief \~english This file contains a interface class for all services classes.
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_SERVICE_H_ // NOLINT (build/header_guard)
44 #define _FRAMEWORKUNIFIED__CWORD77_SERVICE_H_
46 #include <native_service/ns__CWORD77__common.h>
47 #include <native_service/frameworkunified__CWORD77__session_if.h>
52 ///////////////////////////////////////////////////////////////////////////
53 /// class: CFrameworkunified_CWORD77_Service
54 /// Description: This is interface class for all services classes.
56 ////////////////////////////////////////////////////////////////////////////
58 class CFrameworkunified_CWORD77_Service {
60 std::map<UI_32, CFrameworkunified_CWORD77_Session *> m_SessTypeToSessObj; ///< Map of session type to session object
61 ResponseServiceTo_CWORD77_ m_cbResponse; ///< Call back function pointer
62 SessionAckTo_CWORD77_ m_cbSessionACK; // Call back function pointer for session ACK
63 std::vector<FrameworkunifiedNotificationCallbackHandler> m_vServiceNotifications; ///< vector of Frameworkunifiednotification callbacks
64 CFrameworkunified_CWORD77_Session *m_pSession; ///< Pointer to an instance of I_CWORD77_Session
65 std::string m_cServiceName;
66 BOOL m_bServiceAvailable;
67 UI_8 m_ui8SessionRetryCount;
68 HANDLE m_hApp; ///> application framework handle
69 ////////////////////////////////////////////////////////////////////////////////////////////
70 /// \ingroup CFrameworkunified_CWORD77_Service
71 /// \~english @par Brief
72 /// Function to send message to a session
73 /// \~english @param[in] f_uiSessionType
74 /// UI_32 - session type
75 /// \~english @param[in] f_uiSrvProtocol
76 /// UI_32 - Protocol ID
77 /// \~english @retval none
78 /// \~english @par Preconditons
79 /// CFrameworkunified_CWORD77_Service::SetSession()
80 /// \~english @par Change of internal status
81 /// - The internal state is not changed.
82 /// \~english @par Conditions of processing failure
84 /// \~english @par Detail
85 /// Send specified sessionType message by FrameworkunifiedSendMsg().
87 /// If the session object corresponding to the session Public specified by the arguments is not registered,
88 /// the system terminates normally without sending the object.\n
89 /// \~english @par Classification
91 /// \~english @par Type
93 /// \~english @see SetSession,FrameworkunifiedSendMsg
94 ////////////////////////////////////////////////////////////////////////////////////////////
95 void SendMessageToSession(UI_32 f_uiSessionType, UI_32 f_uiSrvProtocol);
97 ////////////////////////////////////////////////////////////////////////////////////////////
98 /// \ingroup CFrameworkunified_CWORD77_Service
99 /// \~english @par Brief
100 /// Function to open sessions with specified Service Name
101 /// \~english @param [in] f_hApp
102 /// f_hApp - Handle to the Framework
105 /// \~english @param [in] f_sServiceName
106 /// f_sServiceName - Service Name
108 /// f_sServiceName - const std::string&
109 /// \~english @retval none
110 /// \~english @par Preconditons
112 /// \~english @par Change of internal status
113 /// - Save service name into member variable.
114 /// \~english @par Conditions of processing failure
116 /// \~english @par Detail
117 /// Function to open sessions with specified Service Name
118 /// \~english @par Classification
120 /// \~english @par Type
122 /// \~english @see none
123 ////////////////////////////////////////////////////////////////////////////////////////////
124 void OpenSession(HANDLE f_hApp, const std::string &f_sServiceName);
126 ////////////////////////////////////////////////////////////////////////////////////////////
127 /// \ingroup CFrameworkunified_CWORD77_Service
128 /// \~english @par Brief
129 /// Function to close sessions
130 /// \~english @param [in] f_hApp
131 /// f_hApp - Handle to the Framework
134 /// \~english @retval none
135 /// \~english @par Preconditons
137 /// \~english @par Change of internal status
138 /// - The internal state is not changed.
139 /// \~english @par Conditions of processing failure
141 /// \~english @par Detail
142 /// Function to close sessions
143 /// \~english @par Classification
145 /// \~english @par Type
147 /// \~english @see none
148 ////////////////////////////////////////////////////////////////////////////////////////////
150 void CloseSession(HANDLE f_hApp);
152 ////////////////////////////////////////////////////////////////////////////////////////////
153 /// \ingroup CFrameworkunified_CWORD77_Service
154 /// \~english @par Brief
155 /// Function to add notification
156 /// \~english @param[in] f_pNotification
157 /// PCSTR - Notification name
158 /// \~english @retval none
159 /// \~english @par Preconditons
160 /// - Session obeject is declared in CFrameworkunified_CWORD77_Service::SetSession()
161 /// \~english @par Change of internal status
162 /// - The internal state is not changed.
163 /// \~english @par Conditions of processing failure
165 /// \~english @par Detail
166 /// -Bind Notification name declared in parameter with callbak function in OnServiceNtf()
167 /// \~english @par Detail
168 /// -subscribed notifications will transfor into subscribe instance in SubscribeNotifications()
169 /// \~english @par Detail
170 /// -Process will not commit when notification parameter name is null
171 /// \~english @par Classification
173 /// \~english @par Type
175 /// \~english @see SetSession,OnServiceNtf,SubscribeNotifications,UnSubscribeNotifications
176 ////////////////////////////////////////////////////////////////////////////////////////////
177 void AddNotification(PCSTR f_pNotification);
179 ////////////////////////////////////////////////////////////////////////////////////////////
180 /// AttachOpenSessionAckCallback
181 /// virtual function to attche open session ack callback
184 /// HANDLE - Handle to the Framework
186 /// EFrameworkunifiedStatus - Success or Error
187 ////////////////////////////////////////////////////////////////////////////////////////////
188 virtual EFrameworkunifiedStatus AttachOpenSessionAckCallback(HANDLE hApp) = 0;
190 ////////////////////////////////////////////////////////////////////////////////////////////
192 /// This function sends open session request to the service m_cServiceName
194 /// \param [in] f_ui32SessionType
195 /// UI_32 - Session type to open
198 ////////////////////////////////////////////////////////////////////////////////////////////
200 void OpenSessionRetry(UI_32 f_ui32SessionType);
203 ////////////////////////////////////////////////////////////////////////////////////////////
204 /// \ingroup CFrameworkunified_CWORD77_Service
205 /// \~english @par Brief
206 /// Constructor for CFrameworkunified_CWORD77_Service
207 /// \~english @retval none
208 /// \~english @par Preconditions
209 /// -No preconditions
210 /// \~english @par Change of internal status
211 /// -The internal state is not changed.
212 /// \~english @par Conditions of processing failure
214 /// \~english @par Detail
215 /// -Create CFrameworkunified_CWORD77_Service class instance
216 /// -Initialize class member variable(m_cbResponse, m_cbSessionACK, m_pSession, m_cServiceName,\n
217 /// m_bServiceAvailable, m_ui8SessionRetryCount, m_hApp, m_SessTypeToSessObj).\n
218 /// \~english @par Classification
220 /// \~english @par type
222 /// \~english @see ~CFrameworkunified_CWORD77_Service
223 ////////////////////////////////////////////////////////////////////////////////////////////
224 CFrameworkunified_CWORD77_Service();
226 ////////////////////////////////////////////////////////////////////////////////////////////
227 /// \ingroup CFrameworkunified_CWORD77_Service
228 /// \~english @par Brief
229 /// Destructor for CFrameworkunified_CWORD77_Service
230 /// \~english @retval none
231 /// \~english @par Preconditons
232 /// -CFrameworkunified_CWORD77_Service instance is decleared in Constructor
233 /// \~english @par Change of internal status
234 /// -The internal status is not changed
235 /// \~english @par Conditions of processing failure
237 /// \~english @par Detail
238 /// -Release the CFrameworkunified_CWORD77_Service class instance
239 /// \~english @par Classification
241 /// \~english @par Type
243 /// \~english @see CFrameworkunified_CWORD77_Service
244 ////////////////////////////////////////////////////////////////////////////////////////////
245 virtual ~CFrameworkunified_CWORD77_Service();
248 ////////////////////////////////////////////////////////////////////////////////////////////
249 /// \ingroup CFrameworkunified_CWORD77_Service
250 /// \~english @par Brief
252 /// virtual function to process message coming from _CWORD77_
253 /// \~english @param [in] cmdID
254 /// cmdID - Request ID
257 /// \~english @retval EFrameworkunifiedStatus
258 /// eFrameworkunifiedStatusOK or Error
259 /// \~english @par Preconditons
260 /// - no preconditions
261 /// \~english @par Change of internal status
262 /// - The internal state is not changed.
263 /// \~english @par Conditions of processing failure
265 /// \~english @par Detail
267 /// \~english @par Classification
269 /// \~english @par Type
271 /// \~english @see none
272 ////////////////////////////////////////////////////////////////////////////////////////////
273 virtual EFrameworkunifiedStatus HandleServiceMessage(UI_32 cmdID) = 0;
276 ////////////////////////////////////////////////////////////////////////////////////////////
277 /// \ingroup CFrameworkunified_CWORD77_Service
278 /// \~english @par Brief
279 /// function to open session with specified Service name when service available.
280 /// \~english @param [in] f_hApp
281 /// f_hApp - Handle to the Framework
284 /// \~english @param [in] f_sServiceName
285 /// f_sServiceName - service name
287 /// f_sServiceName - const std::string &
288 /// \~english @retval EFrameworkunifiedStatus
289 /// eFrameworkunifiedStatusOK or Error
290 /// \~english @par Preconditions
291 /// - no preconditions
292 /// \~english @par Change of internal status
293 /// - save Framework handler into m_hApp.
294 /// \~english @par Conditions of processing failure
296 /// \~english @par Detail
297 /// function to open session with specified Service name
298 /// \~english @par Classification
300 /// \~english @par Type
302 /// \~english @see AttachOpenSessionAckCallback, OpenSession
303 ////////////////////////////////////////////////////////////////////////////////////////////
304 EFrameworkunifiedStatus OpenServiceOnAvailability(HANDLE f_hApp, const std::string &f_sServiceName);
307 ////////////////////////////////////////////////////////////////////////////////////////////
308 /// \ingroup CFrameworkunified_CWORD77_Service
309 /// \~english @par Brief
310 /// function to close session when service unavailable.
311 /// \~english @param [in] f_hApp
312 /// f_hApp - Handle to the Framework
315 /// \~english @retval EFrameworkunifiedStatus
316 /// eFrameworkunifiedStatusOK or Error
317 /// \~english @par Preconditons
318 /// - no preconditions
319 /// \~english @par Change of internal status
320 /// - set m_bServiceAvailable FALSE.
321 /// \~english @par Conditions of processing failure
323 /// \~english @par Detail
324 /// function to close session when service unavailable.
325 /// \~english @par Classification
327 /// \~english @par Type
329 /// \~english @see CloseSession
330 ////////////////////////////////////////////////////////////////////////////////////////////
331 EFrameworkunifiedStatus CloseServiceOnUnavailability(HANDLE hApp);
333 ////////////////////////////////////////////////////////////////////////////////////////////
334 /// \ingroup CFrameworkunified_CWORD77_Service
335 /// \~english @par Brief
336 /// Set Call back function into Sessions.
337 /// \~english @param [in] fptr
338 /// fptr - Pointer to call back function
340 /// fptr ResponseServiceTo_CWORD77_*
341 /// \~english @retval
342 /// \~english @par Preconditons
343 /// - no preconditions
344 /// \~english @par Change of internal status
345 /// - set m_cbResponse with fptr.
346 /// \~english @par Conditions of processing failure
348 /// \~english @par Detail
349 /// Set Call back function into Sessions.
350 /// \~english @par Classification
352 /// \~english @par Type
355 ////////////////////////////////////////////////////////////////////////////////////////////
356 void SetResponseCallback(ResponseServiceTo_CWORD77_ fptr);
358 ////////////////////////////////////////////////////////////////////////////////////////////
359 /// \ingroup CFrameworkunified_CWORD77_Service
360 /// \~english @par Brief
361 /// API to set session objects in service.
362 /// \~english @param [in] f_pSessionObj
363 /// f_pSessionObj - Pointer to an instance of session object.
365 /// f_pSessionObj CFrameworkunified_CWORD77_Session*
366 /// \~english @retval
367 /// \~english @par Preconditons
368 /// - no preconditions
369 /// \~english @par Change of internal status
370 /// - set sessionobj into m_SessTypeToSessObj.
371 /// \~english @par Conditions of processing failure
373 /// \~english @par Detail
374 /// Set session objects in service.
375 /// \~english @par Classification
377 /// \~english @par Type
380 ////////////////////////////////////////////////////////////////////////////////////////////
381 void SetSession(CFrameworkunified_CWORD77_Session *f_pSessionObj);
384 ////////////////////////////////////////////////////////////////////////////////////////////
385 /// \ingroup CFrameworkunified_CWORD77_Service
386 /// \~english @par Brief
387 /// Subscribe notifications.
388 /// \~english @param [in] hApp
389 /// hApp - Handle to the Framework.
392 /// \~english @retval EFrameworkunifiedStatus
393 /// eFrameworkunifiedStatusOK or eFrameworkunifiedStatusInvldParam
394 /// \~english @par Preconditons
395 /// - no preconditions
396 /// \~english @par Change of internal status
397 /// - save pointer of notifications into framework handler.
398 /// \~english @par Conditions of processing failure
399 /// - FrameworkunifiedSubscribeNotificationWithCallback() failed [eFrameworkunifiedStatusInvldParam]
400 /// \~english @par Detail
401 /// Send subscribe message to NPPService for Subscribe notifications.
402 /// \~english @par Classification
404 /// \~english @par Type
406 /// \~english @see FrameworkunifiedSubscribeNotificationWithCallback
407 ////////////////////////////////////////////////////////////////////////////////////////////
408 EFrameworkunifiedStatus SubscribeNotifications(HANDLE hApp);
411 ////////////////////////////////////////////////////////////////////////////////////////////
412 /// \ingroup CFrameworkunified_CWORD77_Service
413 /// \~english @par Brief
414 /// unsubscribe notifications
415 /// \~english @param [in] hApp
416 /// hApp - Handle to the Framework.
419 /// \~english @retval EFrameworkunifiedStatus
420 /// eFrameworkunifiedStatusOK or eFrameworkunifiedStatusInvldParam
421 /// \~english @par Preconditons
422 /// - no preconditions
423 /// \~english @par Change of internal status
424 /// - delete notifications from framework handler.
425 /// \~english @par Conditions of processing failure
426 /// - FrameworkunifiedNPUnsubscribeFromNotifications() failed [eFrameworkunifiedStatusInvldParam]
427 /// \~english @par Detail
428 /// Send unsubscribe message to NPPService for delete subscribe notifications.
429 /// \~english @par Classification
431 /// \~english @par Type
433 /// \~english @see FrameworkunifiedSubscribeNotificationWithCallback
434 ////////////////////////////////////////////////////////////////////////////////////////////
435 EFrameworkunifiedStatus UnSubscribeNotifications(HANDLE hApp);
437 ////////////////////////////////////////////////////////////////////////////////////////////
438 /// \ingroup CFrameworkunified_CWORD77_Service
439 /// \~english @par Brief
440 /// virtual function to enable session in service
441 /// \~english @param [in] f_uiNum
442 /// f_uiNum - Number of arguments
445 /// \~english @param [in] f_uiFirst
446 /// f_uiFirst - first argument
449 /// \~english @retval None
450 /// \~english @par Preconditons
452 /// \~english @par Change of internal status
453 /// - The internal state is not changed.
454 /// \~english @par Conditions of processing failure
456 /// \~english @par Detail
458 /// \~english @par Classification
460 /// \~english @par Type
462 /// \~english @see none
463 ////////////////////////////////////////////////////////////////////////////////////////////
464 virtual void EnableSession(UI_32 f_uiNum, UI_32 f_uiFirst, ...) = 0;
466 ////////////////////////////////////////////////////////////////////////////////////////////
467 /// \ingroup CFrameworkunified_CWORD77_Service
468 /// \~english @par Brief
469 /// unsubscribe notifications
470 /// \~english @param [in] hApp
471 /// hApp - Handle to the Framework.
474 /// \~english @retval EFrameworkunifiedStatus
475 /// eFrameworkunifiedStatusOK or eFrameworkunifiedStatusNullPointer
476 /// \~english @par Preconditons
477 /// - no preconditions
478 /// \~english @par Change of internal status
480 /// \~english @par Conditions of processing failure
481 /// - FrameworkunifiedGetMsgDataOfSize() failed [eFrameworkunifiedStatusNullPointer]
482 /// \~english @par Detail
483 /// Call register subscribe notification.
484 /// \~english @par Classification
486 /// \~english @par Type
488 /// \~english @see FrameworkunifiedGetMsgDataOfSize, SetRespNotfnDataIn_CWORD77_DataPool
489 ////////////////////////////////////////////////////////////////////////////////////////////
490 EFrameworkunifiedStatus OnServiceNtf(HANDLE hApp);
492 ////////////////////////////////////////////////////////////////////////////////////////////
493 /// \ingroup CFrameworkunified_CWORD77_Service
494 /// \~english @par Brief
495 /// Acknowledgement process of open session
496 /// \~english @param[in] f_hApp
497 /// HANDLE - Handle to the Application
498 /// \~english @retval none
499 /// \~english @par Preconditons
500 /// - Set Session object in CFrameworkunified_CWORD77_Service::SetSession()
501 /// - Set Callback function in CFrameworkunified_CWORD77_Service::Set_CWORD77_OpenSessionACK()
502 /// \~english @par Change of internal status
504 /// \~english @par Conditions of processing failure
506 /// \~english @par Detail
507 /// Set the application handle as Parameter when receiving acknowledgement for open session process.
508 /// Call OpenSessionAcknowledge() in session object which has same session type.
509 /// Call the callback function for open session acknowledgement.
511 /// Message sending process will be stoped in reguler when the session type of open session process is not
514 /// Callback function will be stoped in reguler when callback function is not declared.
515 /// \~english @par Classification
517 /// \~english @par Type
519 /// \~english @see SetSession,Set_CWORD77_OpenSessionACK
520 ////////////////////////////////////////////////////////////////////////////////////////////
521 void OpenSessionAcks(HANDLE f_hApp);
523 ////////////////////////////////////////////////////////////////////////////////////////////
524 /// \ingroup CFrameworkunified_CWORD77_Service
525 /// \~english @par Brief
526 /// Attach open session ack callback function to service.
527 /// \~english @param [in] fptr
528 /// fptr - Callback Function pointer of notify open session ack.
530 /// fptr SessionAckTo_CWORD77_*
531 /// \~english @retval
532 /// \~english @par Preconditons
533 /// - no preconditions
534 /// \~english @par Change of internal status
535 /// - set callback function into m_cbSessionACK..
536 /// \~english @par Conditions of processing failure
538 /// \~english @par Detail
539 /// Attach open session ack callback function to service.
540 /// \~english @par Classification
542 /// \~english @par Type
544 /// \~english @see none
545 ////////////////////////////////////////////////////////////////////////////////////////////
546 void Set_CWORD77_OpenSessionACK(SessionAckTo_CWORD77_ fptr);
549 #endif // _FRAMEWORKUNIFIED__CWORD77_SERVICE_H_ NOLINT (build/header_guard)