Remove unused directories and files in video_in_hal
[staging/basesystem.git] / nsframework / notification_persistent_service / server / include / ns_npp_nor_persistence_worker_thread.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 /// \defgroup <<Group Tag>> <<Group Name>>
19 /// \ingroup  tag_NS_NPPService
20 /// .
21 ////////////////////////////////////////////////////////////////////////////////////////////////////
22
23 ////////////////////////////////////////////////////////////////////////////////////////////////////
24 /// \ingroup  tag_NS_NPPService
25 /// \brief    This file contain declaration of class CImmediatePersistenceWorker and holds the
26 ///           implementation for worker thread.
27 ///
28 ////////////////////////////////////////////////////////////////////////////////////////////////////
29
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_
32
33 #include <native_service/frameworkunified_types.h>
34 #include <native_service/ns_timer_if.hpp>
35
36 #include "ns_npp_types.h"
37
38 ////////////////////////////////////////////////////////////////////////////////////////////////
39 /// NSP_NorPersistenceWorkerOnStart
40 /// Callback method on start of worker thread.
41 ///
42 /// \param [IN] hthread
43 ///      HANDLE - Thread Handle
44 ///
45 /// \return EFrameworkunifiedStatus
46 //      EFrameworkunifiedStatus - success or failure status
47 ///
48 ////////////////////////////////////////////////////////////////////////////////////////////////
49 EFrameworkunifiedStatus NSPNorPersistenceWorkerOnStart(HANDLE hthread);
50
51 ////////////////////////////////////////////////////////////////////////////////////////////////
52 /// NSPNorPersistenceWorkerOnStop
53 /// Callback method on stopping of worker thread.
54 ///
55 /// \param [IN] hthread
56 ///      HANDLE - Thread Handle
57 ///
58 /// \return EFrameworkunifiedStatus
59 //      EFrameworkunifiedStatus - success or failure status
60 ///
61 ////////////////////////////////////////////////////////////////////////////////////////////////
62 EFrameworkunifiedStatus NSPNorPersistenceWorkerOnStop(HANDLE hthread);
63
64 // Forward Declaration for class
65 class CNotificationsToPersist;
66
67
68 /**
69  *  This class handles the immediate persistence notification related requests.
70  *
71  */
72 class CNorPersistenceWorker {
73  public:
74   ////////////////////////////////////////////////////////////////////////////////////////////////
75   /// CNorPersistenceWorker
76   /// Constructor of class CNorPersistenceWorker
77   ///
78   ////////////////////////////////////////////////////////////////////////////////////////////////
79   CNorPersistenceWorker();
80
81   ////////////////////////////////////////////////////////////////////////////////////////////////
82   /// ~CNorPersistenceWorker
83   /// Destructor of class CNorPersistenceWorker
84   ///
85   ////////////////////////////////////////////////////////////////////////////////////////////////
86   ~CNorPersistenceWorker();
87
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.
94   ///
95   /// \param [IN] f_hthread
96   ///      HANDLE - Thread Handle
97   ///
98   /// \return EFrameworkunifiedStatus
99   //      EFrameworkunifiedStatus - success or failure status
100   ///
101   ////////////////////////////////////////////////////////////////////////////////////////////////
102   EFrameworkunifiedStatus OnNorPersistenceTimerStart(HANDLE hthread);
103
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.
110   ///
111   /// \param [IN] f_hthread
112   ///      HANDLE - Thread Handle
113   ///
114   /// \return EFrameworkunifiedStatus
115   //      EFrameworkunifiedStatus - success or failure status
116   ///
117   ////////////////////////////////////////////////////////////////////////////////////////////////
118   EFrameworkunifiedStatus RegisterImmediatePersistNotification(HANDLE hthread);
119
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.
125   ///
126   /// \param [IN] f_hthread
127   ///      HANDLE - Thread Handle
128   ///
129   /// \return EFrameworkunifiedStatus
130   //      EFrameworkunifiedStatus - success or failure status
131   ///
132   ////////////////////////////////////////////////////////////////////////////////////////////////
133   EFrameworkunifiedStatus UnregisterImmediatePersistNotification(HANDLE hthread);
134
135   ////////////////////////////////////////////////////////////////////////////////////////////////
136   /// OnShutdown
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 .
140   ///
141   /// \param [IN] f_hthread
142   ///      HANDLE - Thread Handle
143   ///
144   /// \return EFrameworkunifiedStatus
145   //      EFrameworkunifiedStatus - success or failure status
146   ///
147   ////////////////////////////////////////////////////////////////////////////////////////////////
148   EFrameworkunifiedStatus OnShutdown(HANDLE hthread);
149
150
151   ////////////////////////////////////////////////////////////////////////////////////////////////
152   /// OnCategoryChange
153   /// This API updates the category of immediate persistence notification.
154   ///
155   /// \param [IN] f_hthread
156   ///        HANDLE - Thread Handle
157   ///
158   /// \return EFrameworkunifiedStatus
159   //          EFrameworkunifiedStatus - success or failure status
160   ///
161   ////////////////////////////////////////////////////////////////////////////////////////////////
162   EFrameworkunifiedStatus OnCategoryChange(HANDLE hthread);
163 };
164
165 /**
166  *  CTimerHelper class maps the timer id and corresponding data.
167  *
168  */
169 class CTimerHelper: public NSTimer {
170  public:
171   ////////////////////////////////////////////////////////////////////////////////////////////////
172   /// CTimerHelper
173   /// Constructor of class CTimerHelper
174   ///
175   ////////////////////////////////////////////////////////////////////////////////////////////////
176   CTimerHelper();
177
178   ////////////////////////////////////////////////////////////////////////////////////////////////
179   /// ~CTimerHelper
180   /// Destructor of class CTimerHelper
181   ///
182   ////////////////////////////////////////////////////////////////////////////////////////////////
183   ~CTimerHelper();
184
185   ////////////////////////////////////////////////////////////////////////////////////////////////
186   /// GetCmdId
187   /// Returns the timer id of the timer.
188   ///
189   /// \param [IN] none
190   ///
191   /// \return UI_32
192   //      UI_32 - Timer id of the timer
193   ///
194   ////////////////////////////////////////////////////////////////////////////////////////////////
195   UI_32 GetCmdId();
196
197   ////////////////////////////////////////////////////////////////////////////////////////////////
198   /// OnTimeOut
199   /// This function gets called when timer expires. This function writes the notification data in
200   /// persistent memory.
201   ///
202   /// \param [IN] f_hthread
203   ///      HANDLE - Thread Handle
204   ///
205   /// \return EFrameworkunifiedStatus
206   //      EFrameworkunifiedStatus - success or failure status
207   ///
208   ////////////////////////////////////////////////////////////////////////////////////////////////
209   EFrameworkunifiedStatus OnTimeOut(HANDLE hthread);
210
211   // member variables
212   PUI_8 m_pui8HeaderAndData;  // header and corresponding data of the notfn stored as part of timer
213
214  private:
215   UI_32 m_uiCmdId;  // command id associated with timer
216 };
217
218 #endif  // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_NOR_PERSISTENCE_WORKER_THREAD_H_