Remove unused directories and files in video_in_hal
[staging/basesystem.git] / nsframework / framework_unified / client / include / native_service / ns__CWORD77__common.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  * @file ns__CWORD77__common.h
19  * @brief \~english This file has templet class declaration of CCallback and CResCallback
20  *
21  */
22 /** @addtogroup BaseSystem
23  *  @{
24  */
25 /** @addtogroup native_service
26  *  @ingroup BaseSystem
27  *  @{
28  */
29 /** @addtogroup framework_unified
30  *  @ingroup native_service
31  *  @{
32  */
33 /** @addtogroup _CWORD77_
34  *  @ingroup framework_unified
35  *  @{
36  */
37 #ifndef _NS__CWORD77_COMMON_H_  // NOLINT  (build/header_guard)
38 #define _NS__CWORD77_COMMON_H_
39
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>
44
45 #include <cstdlib>
46 #include <iostream>
47 #include <string>
48
49 #define MAX_DATA_SIZE 512;
50 // using namespace std;
51
52
53 // typedef string ServiceName;
54
55
56 #define DELETEPTR(p) {if (p != NULL) {delete p; p = NULL;}}
57
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_;
61
62 // typedef EFrameworkunifiedStatus (*_CWORD77_TimeoutFuncPtr)(HANDLE hApp,UI_32 uiCmdId, E_CWORD77_MessageType MessageType);
63
64 template <typename C, EFrameworkunifiedStatus(C::*M)(HANDLE)>
65 class CCallback {
66  public:
67   static CallbackFunctionPtr set(void *pInst) {
68     if (pInst == NULL) {
69       throw;
70     }
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
74     }
75     ms_pInst = pInst;
76     return &CCallback::call;
77   }
78   static EFrameworkunifiedStatus call(HANDLE y) {
79     if (ms_pInst == NULL) {
80       return eFrameworkunifiedStatusFault;  // can't throw here
81     }
82     C *c = static_cast<C *>(ms_pInst);
83     return (c->*M)(y);
84   }
85  private:
86   static void *ms_pInst;
87 };
88
89
90
91 template <typename C, EFrameworkunifiedStatus(C::*M)(HANDLE)>
92 void *CCallback<C, M>::ms_pInst = NULL;
93
94
95
96 template <typename C, EFrameworkunifiedStatus(C::*M)(HANDLE, E_CWORD77_ResponseType, std::string)>
97 class CResCallback {
98  public:
99   static ResponseServiceTo_CWORD77_ set(void *pInst) {
100     if (pInst == NULL) {
101       throw;
102     }
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
106     }
107     ms_pInst = pInst;
108     return &CResCallback::call;
109   }
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
113     }
114     C *c = static_cast<C *>(ms_pInst);
115     return (c->*M)(y, ResponseType, ServiceName);
116   }
117  private:
118   static void *ms_pInst;
119 };
120
121 template <typename C, EFrameworkunifiedStatus(C::*M)(HANDLE, E_CWORD77_ResponseType, std::string)>
122 void *CResCallback<C, M>::ms_pInst = NULL;
123
124
125 #endif  // _NS__CWORD77_COMMON_H_ NOLINT  (build/header_guard)
126 /** @}*/
127 /** @}*/
128 /** @}*/
129 /** @}*/