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 /// \defgroup <<Group Tag>> <<Group Name>>
19 /// \ingroup tag_NS_NPPService
21 ////////////////////////////////////////////////////////////////////////////////////////////////////
23 ////////////////////////////////////////////////////////////////////////////////////////////////////
24 /// \ingroup tag_NS_NPPService
25 /// \brief This file contain declaration of class CImmediatePersistenceWorker and holds the
26 /// implementation for worker thread.
28 ////////////////////////////////////////////////////////////////////////////////////////////////////
30 #ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_NOR_PERSISTENCE_WORKER_THREAD_H_
31 #define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_NOR_PERSISTENCE_WORKER_THREAD_H_
33 #include <native_service/frameworkunified_types.h>
34 #include <native_service/ns_timer_if.hpp>
36 #include "ns_npp_types.h"
38 ////////////////////////////////////////////////////////////////////////////////////////////////
39 /// NSP_NorPersistenceWorkerOnStart
40 /// Callback method on start of worker thread.
42 /// \param [IN] hthread
43 /// HANDLE - Thread Handle
45 /// \return EFrameworkunifiedStatus
46 // EFrameworkunifiedStatus - success or failure status
48 ////////////////////////////////////////////////////////////////////////////////////////////////
49 EFrameworkunifiedStatus NSPNorPersistenceWorkerOnStart(HANDLE hthread);
51 ////////////////////////////////////////////////////////////////////////////////////////////////
52 /// NSPNorPersistenceWorkerOnStop
53 /// Callback method on stopping of worker thread.
55 /// \param [IN] hthread
56 /// HANDLE - Thread Handle
58 /// \return EFrameworkunifiedStatus
59 // EFrameworkunifiedStatus - success or failure status
61 ////////////////////////////////////////////////////////////////////////////////////////////////
62 EFrameworkunifiedStatus NSPNorPersistenceWorkerOnStop(HANDLE hthread);
64 // Forward Declaration for class
65 class CNotificationsToPersist;
69 * This class handles the immediate persistence notification related requests.
72 class CNorPersistenceWorker {
74 ////////////////////////////////////////////////////////////////////////////////////////////////
75 /// CNorPersistenceWorker
76 /// Constructor of class CNorPersistenceWorker
78 ////////////////////////////////////////////////////////////////////////////////////////////////
79 CNorPersistenceWorker();
81 ////////////////////////////////////////////////////////////////////////////////////////////////
82 /// ~CNorPersistenceWorker
83 /// Destructor of class CNorPersistenceWorker
85 ////////////////////////////////////////////////////////////////////////////////////////////////
86 ~CNorPersistenceWorker();
88 ////////////////////////////////////////////////////////////////////////////////////////////////
89 /// OnNorPersistenceTimerStart
90 /// When immediate persistence notification publish request is received by NPPService. It sends a
91 /// NOR_PERSISTENCE_TIMER_START command to the worker thread and this function gets called.
92 /// This function starts the respective timer of the notification. Timeout of timer writes
93 /// corresponding notification data to persistent memory.
95 /// \param [IN] f_hthread
96 /// HANDLE - Thread Handle
98 /// \return EFrameworkunifiedStatus
99 // EFrameworkunifiedStatus - success or failure status
101 ////////////////////////////////////////////////////////////////////////////////////////////////
102 EFrameworkunifiedStatus OnNorPersistenceTimerStart(HANDLE hthread);
104 ////////////////////////////////////////////////////////////////////////////////////////////////
105 /// RegisterImmediatePersistNotification
106 /// When immediate persistence notification register request is received by NPPService. It sends a
107 /// NOR_PERSISTENCE_REGISTER command to the worker thread and this function gets called.
108 /// Registration with worker thread is required because only child thread will be responsible for
109 /// data saving related stuff. It creates a timer corresponding to the notification.
111 /// \param [IN] f_hthread
112 /// HANDLE - Thread Handle
114 /// \return EFrameworkunifiedStatus
115 // EFrameworkunifiedStatus - success or failure status
117 ////////////////////////////////////////////////////////////////////////////////////////////////
118 EFrameworkunifiedStatus RegisterImmediatePersistNotification(HANDLE hthread);
120 ////////////////////////////////////////////////////////////////////////////////////////////////
121 /// UnregisterImmediatePersistNotification
122 /// When immediate persistence notification unregister request is received by NPPService. It sends a
123 /// NOR_PERSISTENCE_UNREGISTER command to the worker thread and this function gets called.
124 /// It deletes a timer corresponding to the notification.
126 /// \param [IN] f_hthread
127 /// HANDLE - Thread Handle
129 /// \return EFrameworkunifiedStatus
130 // EFrameworkunifiedStatus - success or failure status
132 ////////////////////////////////////////////////////////////////////////////////////////////////
133 EFrameworkunifiedStatus UnregisterImmediatePersistNotification(HANDLE hthread);
135 ////////////////////////////////////////////////////////////////////////////////////////////////
137 /// This API stops all the immediate notification timer.
138 /// This API immediately writes the data to persistent memory if the timer is runnning,
139 /// irrespective of delay unless the data .
141 /// \param [IN] f_hthread
142 /// HANDLE - Thread Handle
144 /// \return EFrameworkunifiedStatus
145 // EFrameworkunifiedStatus - success or failure status
147 ////////////////////////////////////////////////////////////////////////////////////////////////
148 EFrameworkunifiedStatus OnShutdown(HANDLE hthread);
151 ////////////////////////////////////////////////////////////////////////////////////////////////
153 /// This API updates the category of immediate persistence notification.
155 /// \param [IN] f_hthread
156 /// HANDLE - Thread Handle
158 /// \return EFrameworkunifiedStatus
159 // EFrameworkunifiedStatus - success or failure status
161 ////////////////////////////////////////////////////////////////////////////////////////////////
162 EFrameworkunifiedStatus OnCategoryChange(HANDLE hthread);
166 * CTimerHelper class maps the timer id and corresponding data.
169 class CTimerHelper: public NSTimer {
171 ////////////////////////////////////////////////////////////////////////////////////////////////
173 /// Constructor of class CTimerHelper
175 ////////////////////////////////////////////////////////////////////////////////////////////////
178 ////////////////////////////////////////////////////////////////////////////////////////////////
180 /// Destructor of class CTimerHelper
182 ////////////////////////////////////////////////////////////////////////////////////////////////
185 ////////////////////////////////////////////////////////////////////////////////////////////////
187 /// Returns the timer id of the timer.
192 // UI_32 - Timer id of the timer
194 ////////////////////////////////////////////////////////////////////////////////////////////////
197 ////////////////////////////////////////////////////////////////////////////////////////////////
199 /// This function gets called when timer expires. This function writes the notification data in
200 /// persistent memory.
202 /// \param [IN] f_hthread
203 /// HANDLE - Thread Handle
205 /// \return EFrameworkunifiedStatus
206 // EFrameworkunifiedStatus - success or failure status
208 ////////////////////////////////////////////////////////////////////////////////////////////////
209 EFrameworkunifiedStatus OnTimeOut(HANDLE hthread);
212 PUI_8 m_pui8HeaderAndData; // header and corresponding data of the notfn stored as part of timer
215 UI_32 m_uiCmdId; // command id associated with timer
218 #endif // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_NOR_PERSISTENCE_WORKER_THREAD_H_