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.
18 * @file ns__CWORD77__common.h
19 * @brief \~english This file has templet class declaration of CCallback and CResCallback
22 /** @addtogroup BaseSystem
25 /** @addtogroup native_service
29 /** @addtogroup framework_unified
30 * @ingroup native_service
33 /** @addtogroup _CWORD77_
34 * @ingroup framework_unified
37 #ifndef _NS__CWORD77_COMMON_H_ // NOLINT (build/header_guard)
38 #define _NS__CWORD77_COMMON_H_
40 #include <native_service/frameworkunified_service_protocol.h>
41 #include <native_service/frameworkunified_framework_types.h>
42 #include <native_service/frameworkunified_framework_if.h>
43 #include <native_service/ns__CWORD77__types.h>
49 #define MAX_DATA_SIZE 512;
50 // using namespace std;
53 // typedef string ServiceName;
56 #define DELETEPTR(p) {if (p != NULL) {delete p; p = NULL;}}
58 typedef EFrameworkunifiedStatus(*_CWORD77_FuncPtr)(HANDLE hApp, BOOL bTImerExpiry);
59 typedef EFrameworkunifiedStatus(*ResponseServiceTo_CWORD77_)(HANDLE hApp, E_CWORD77_ResponseType ResponseType, std::string ServiceName);
60 typedef boost::function< EFrameworkunifiedStatus(HANDLE, std::string, std::string, UI_32, EFrameworkunifiedStatus) > SessionAckTo_CWORD77_;
62 // typedef EFrameworkunifiedStatus (*_CWORD77_TimeoutFuncPtr)(HANDLE hApp,UI_32 uiCmdId, E_CWORD77_MessageType MessageType);
64 template <typename C, EFrameworkunifiedStatus(C::*M)(HANDLE)>
67 static CallbackFunctionPtr set(void *pInst) {
71 if (ms_pInst != NULL) {
72 // TODO(framework_unified): FRAMEWORKUNIFIEDLOG some warning, preferably outside the template (i.e. use a global),
73 // to limit executable size, as this code will be replicated many times over
76 return &CCallback::call;
78 static EFrameworkunifiedStatus call(HANDLE y) {
79 if (ms_pInst == NULL) {
80 return eFrameworkunifiedStatusFault; // can't throw here
82 C *c = static_cast<C *>(ms_pInst);
86 static void *ms_pInst;
91 template <typename C, EFrameworkunifiedStatus(C::*M)(HANDLE)>
92 void *CCallback<C, M>::ms_pInst = NULL;
96 template <typename C, EFrameworkunifiedStatus(C::*M)(HANDLE, E_CWORD77_ResponseType, std::string)>
99 static ResponseServiceTo_CWORD77_ set(void *pInst) {
103 if (ms_pInst != NULL) {
104 // TODO(framework_unified): FRAMEWORKUNIFIEDLOG some warning, preferably outside the template (i.e. use a global),
105 // to limit executable size, as this code will be replicated many times over
108 return &CResCallback::call;
110 static EFrameworkunifiedStatus call(HANDLE y, E_CWORD77_ResponseType ResponseType, std::string ServiceName) {
111 if (ms_pInst == NULL) {
112 return eFrameworkunifiedStatusFault; // can't throw here
114 C *c = static_cast<C *>(ms_pInst);
115 return (c->*M)(y, ResponseType, ServiceName);
118 static void *ms_pInst;
121 template <typename C, EFrameworkunifiedStatus(C::*M)(HANDLE, E_CWORD77_ResponseType, std::string)>
122 void *CResCallback<C, M>::ms_pInst = NULL;
125 #endif // _NS__CWORD77_COMMON_H_ NOLINT (build/header_guard)