common_library: gettid is multiple declaration in cl_error
[staging/basesystem.git] / video_in_hal / nsframework / notification_persistent_service / server / include / ns_npp_notification_manager.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 contains declaration of singleton class CNotificationManager which is used
26 ///       to manage notification information.
27 ///
28 ////////////////////////////////////////////////////////////////////////////////////////////////////
29 #ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_NOTIFICATION_MANAGER_H_
30 #define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_NOTIFICATION_MANAGER_H_
31
32 ////////////////////////////////////////////////////////////////////////////////////////////////////
33 // Include Files
34 ////////////////////////////////////////////////////////////////////////////////////////////////////
35 #include <native_service/frameworkunified_types.h>
36 #include <native_service/ns_np_service.h>
37
38 #include <map>
39 #include <vector>
40 #include <string>
41 #include <iostream>
42
43 /// forward declaration of class
44 class CNotification;
45 class CPersistentData;
46 class CNotificationsToPersist;
47 class CStateNotification;
48
49 /// map of all the available notification.
50 typedef std::map<std::string, CNotification *> Notification_Type;
51
52 /// iterator for map of notifications.
53 typedef  Notification_Type::iterator Notification_Iterator_Type;
54
55 /// map of all available persistent notification and its data.
56 typedef std::map<std::string, CPersistentData *> Persistent_Type;
57
58 /// Iterator for map of persistent notifications.
59 typedef  Persistent_Type::iterator Persistent_Iterator_Type;
60
61 /**
62  *  This class is used to manage the operations related to notification
63  *  on registration, subscription, publication, etc.
64  */
65 class CNotificationManager {
66  public:
67   ////////////////////////////////////////////////////////////////////////////////////////////////
68   /// CNotificationManager
69   /// Constructor of CNotificationManager class
70   ///
71   /// \param
72   ///
73   /// \return
74   ///
75   ////////////////////////////////////////////////////////////////////////////////////////////////
76   CNotificationManager();
77
78   ////////////////////////////////////////////////////////////////////////////////////////////////
79   /// ~CNotificationManager
80   /// Destructor of CNotificationManager class
81   ///
82   /// \param
83   ///
84   /// \return
85   ///
86   ////////////////////////////////////////////////////////////////////////////////////////////////
87   ~CNotificationManager();
88
89   ////////////////////////////////////////////////////////////////////////////////////////////////
90   /// NotificationpersistentserviceServiceOnRegisterEvents
91   /// This function creates notification object depending on its type and if already created it
92   /// adds the service name to the list in the notification object.
93   ///
94   /// \param  [IN] f_cservicename
95   ///     std::string - name of service registering for notification
96   ///
97   /// \param  [IN] f_cnotificationname
98   ///     std::string - notification name
99   ///
100   /// \param  [IN] f_uimsglength
101   ///     UI_32 - Maximum length of Message
102   ///
103   /// \param  [IN] f_enotificationtype
104   ///     EFrameworkunifiedPersistentVarType - type of notification
105   ///
106   /// \param  [IN] f_uidelay
107   ///     UI_32 - Delay time for persistence
108   ///
109   /// \return EFrameworkunifiedStatus
110   //      EFrameworkunifiedStatus - success or failure status
111   ///
112   ////////////////////////////////////////////////////////////////////////////////////////////////
113   EFrameworkunifiedStatus NotificationpersistentserviceServiceOnRegisterEvents(const std::string &f_cservicename,
114                                         const std::string &f_cnotificationname,
115                                         const UI_32 f_uimsglength,
116                                         const EFrameworkunifiedNotificationType f_enotificationtype,
117                                         const UI_32 f_uidelay = 0);
118
119   ////////////////////////////////////////////////////////////////////////////////////////////////
120   /// NotificationpersistentserviceServiceOnUnRegisterEvents
121   /// This function removes the name of the service from the notification object.
122   ///
123   /// \param  [IN] f_cservicename
124   ///     std::string - name of service unregistering from notification
125   ///
126   /// \param  [IN] f_cnotificationname
127   ///     std::string - notification name
128   ///
129   /// \return EFrameworkunifiedStatus
130   //      EFrameworkunifiedStatus - success or failure status
131   ///
132   ///
133   ////////////////////////////////////////////////////////////////////////////////////////////////
134   EFrameworkunifiedStatus NotificationpersistentserviceServiceOnUnRegisterEvents(const std::string &f_cservicename,
135                                           const std::string &f_cnotificationname);
136
137   ////////////////////////////////////////////////////////////////////////////////////////////////
138   /// NotificationpersistentserviceServiceOnPublishEvent
139   /// This function stores the published data in the notification object in case of state and
140   /// persistent notification.
141   ///
142   /// \param  [IN] f_cservicename
143   ///     std::string - name of service registering for notification
144   ///
145   /// \param  [IN] f_cnotificationname
146   ///     std::string - notification name
147   ///
148   /// \param  [IN] f_pmessage
149   ///     PVOID - pointer to message
150   ///
151   /// \param  f_uimsgsize
152   ///     UI_32 - size of Message
153   ///
154   /// \return EFrameworkunifiedStatus
155   //      EFrameworkunifiedStatus - success or failure status
156   ///
157   ////////////////////////////////////////////////////////////////////////////////////////////////
158   EFrameworkunifiedStatus NotificationpersistentserviceServiceOnPublishEvent(const std::string &f_cservicename,
159                                       const std::string &f_cnotificationname,
160                                       PVOID f_pmessage,
161                                       const UI_32 f_uimsgsize);
162
163   ////////////////////////////////////////////////////////////////////////////////////////////////
164   /// NotificationpersistentserviceServiceOnSubscribeToEvent
165   /// This function adds the name of the application to subscribers list in notification object.
166   ///
167   /// \param  [IN] f_csubscribername
168   ///     std::string - name of application subscribing to notification
169   ///
170   /// \param  [IN] f_cnotificationname
171   ///     std::string - notification name
172   ///
173   /// \return EFrameworkunifiedStatus
174   //      EFrameworkunifiedStatus - success or failure status
175   ///
176   ///
177   ////////////////////////////////////////////////////////////////////////////////////////////////
178   EFrameworkunifiedStatus NotificationpersistentserviceServiceOnSubscribeToEvent(const std::string &f_csubscribername,
179                                           const std::string &f_cnotificationname);
180
181   ////////////////////////////////////////////////////////////////////////////////////////////////
182   /// NotificationpersistentserviceServiceOnUnSubscribeFromEvent
183   /// This function adds the name of the application to subscribers list in notification object.
184   ///
185   /// \param  [IN] f_csubscribername
186   ///     std::string - name of application subscribing to notification
187   ///
188   /// \param  [IN] f_cnotificationname
189   ///     std::string - notification name
190   ///
191   /// \return EFrameworkunifiedStatus
192   //      EFrameworkunifiedStatus - success or failure status
193   ///
194   ///
195   ////////////////////////////////////////////////////////////////////////////////////////////////
196   EFrameworkunifiedStatus NotificationpersistentserviceServiceOnUnSubscribeFromEvent(const std::string &f_csubscribername,
197                                               const std::string &f_cnotificationname);
198
199   ////////////////////////////////////////////////////////////////////////////////////////////////
200   /// NPGetPersistentNotificationData
201   /// Get data for notification name
202   ///
203   /// \param  [IN] f_cnotificationname
204   ///     std::string - name of notification
205   /// \param  [OUT] f_pnotificationdata
206   ///     PVOID - data corresponding to notification name
207   /// \param  [IN] f_uidatasize
208   ///     UI_32 - size of data
209   ///
210   /// \return EFrameworkunifiedStatus
211   //      EFrameworkunifiedStatus - success or failure status
212   ///
213   ///
214   ////////////////////////////////////////////////////////////////////////////////////////////////
215   EFrameworkunifiedStatus NPGetPersistentNotificationData(const std::string &f_cnotificationname,
216                                              PVOID f_pnotificationdata, const UI_32 f_uidatasize);
217
218   ////////////////////////////////////////////////////////////////////////////////////////////////
219   /// NotificationpersistentserviceServiceOnGetPersistentData
220   /// This function is used to get the persistent data stored related to notification.
221   ///
222   /// \param  [IN] f_cnotificationname
223   ///     std::string - Notification Name
224   ///
225   /// \param  [IN] f_creceivername
226   ///     std::string - Source Name
227   ///
228   /// \return EFrameworkunifiedStatus
229   //      EFrameworkunifiedStatus - success or failure status
230   ///
231   ////////////////////////////////////////////////////////////////////////////////////////////////
232   EFrameworkunifiedStatus NotificationpersistentserviceServiceOnGetPersistentData(const std::string &f_cnotificationname,
233                                            const std::string &f_creceivername);
234
235   ////////////////////////////////////////////////////////////////////////////////////////////////
236   /// NotificationpersistentserviceGetPersistentNotificationData
237   /// This function is used to get the list of persistent notifications and the data associated
238   /// with it.
239   ///
240   /// \param  [OUT] f_pvpersistnotification
241   ///     CNotificationsToPersist - vector containing list of persistent notifications and
242   ///     data associated with it.
243   ///
244   /// \param  [IN] f_enotificationtype
245   ///     EFrameworkunifiedNotificationType - Type of notification
246   ///
247   /// \param  [IN] f_uinotificationpersistentservicepersistcategoryflag
248   ///     UI_32 - Hex value from enum EFrameworkunifiedPersistCategory, representing data to persist
249   ///     0 - persist orignal data and
250   ///     1 - persist default data
251   ///
252   /// \return EFrameworkunifiedStatus
253   //      EFrameworkunifiedStatus - success or failure status
254   ///
255   ////////////////////////////////////////////////////////////////////////////////////////////////
256   EFrameworkunifiedStatus NotificationpersistentserviceGetPersistentNotificationData(std::vector<CNotificationsToPersist *> *f_pvpersistnotification,
257                                               const EFrameworkunifiedNotificationType f_enotificationtype,
258                                               UI_32 f_uinotificationpersistentservicepersistcategoryflag);
259
260   ////////////////////////////////////////////////////////////////////////////////////////////////
261   /// NotificationpersistentserviceSetPersistentNotificationData
262   /// This function is used to create the persistent notifications object and fill the data
263   /// related with it on system load.
264   ///
265   /// \param  [IN] f_pvpersistnotification
266   ///     vector<CNotificationsToPersist> - vector containing list of notifications and data associated with it
267   ///
268   /// \return EFrameworkunifiedStatus
269   //      EFrameworkunifiedStatus - success or failure status
270   ///
271   ////////////////////////////////////////////////////////////////////////////////////////////////
272   EFrameworkunifiedStatus NotificationpersistentserviceSetPersistentNotificationData(std::vector<CNotificationsToPersist *> *f_pvpersistnotification);
273
274   ////////////////////////////////////////////////////////////////////////////////////////////////
275   /// GetNotificationInfo
276   /// This function is used to get the notification information.
277   ///
278   /// \param  [IN] f_cnotificationname
279   ///     std::string - Notification Name
280   ///
281   /// \param  [IN] l_pnotificationstopersist
282   ///     CNotificationsToPersist - Notification info structure
283   ///
284   /// \return EFrameworkunifiedStatus
285   //      EFrameworkunifiedStatus - success or failure status
286   ///
287   ////////////////////////////////////////////////////////////////////////////////////////////////
288   EFrameworkunifiedStatus GetNotificationInfo(const std::string &f_cnotificationname,
289                                  CNotificationsToPersist *&l_pnotificationstopersist); // NOLINT (runtime/references)
290
291   ////////////////////////////////////////////////////////////////////////////////////////////////
292   /// NotificationpersistentserviceSetDefaultPersistentNotificationData
293   /// This function is used to set the default data of persistent notification
294   ///
295   /// \param  [IN] f_cnotificationname
296   ///     std::string - notification name
297   /// \param  [IN] f_pmessage
298   ///     PVOID - message data
299   /// \param  [IN] f_uimsgsize
300   ///     UI_32 - message size
301   ///
302   /// \return EFrameworkunifiedStatus
303   //      EFrameworkunifiedStatus - success or failure status
304   ///
305   ////////////////////////////////////////////////////////////////////////////////////////////////
306   EFrameworkunifiedStatus NotificationpersistentserviceSetDefaultPersistentNotificationData(const std::string &f_cnotificationname,
307                                                      PVOID f_pmessage,
308                                                      const UI_32 f_uimsgsize);
309
310   ////////////////////////////////////////////////////////////////////////////////////////////////
311   /// NotificationpersistentserviceSetPersistentCategory
312   /// This function is used to set the persistent type of persistent notification
313   ///
314   /// \param  [IN] f_cnotificationname
315   ///     std::string - notification name
316   /// \param  [IN] f_epersistenttype
317   ///     EFrameworkunifiedPersistCategory - persistent category
318   ///
319   /// \return EFrameworkunifiedStatus
320   //      EFrameworkunifiedStatus - success or failure status
321   ///
322   ////////////////////////////////////////////////////////////////////////////////////////////////
323   EFrameworkunifiedStatus NotificationpersistentserviceSetPersistentCategory(const std::string &f_cnotificationname,
324                                       const EFrameworkunifiedPersistCategory f_epersistcategory);
325
326   ////////////////////////////////////////////////////////////////////////////////////////////////
327   /// NotificationpersistentservicePublishImmediateNotification
328   /// This function publish the immediate notification f_cnotificationname to all its subscribers.
329   /// This API is called when service updates the immediate notification data in persistent memory
330   /// using synchronous API.
331   ///
332   /// \param  [IN] f_cservicename
333   ///         const std::string& - name of service registering for notification
334   ///
335   /// \param  [IN] f_cnotificationname
336   ///         const std::string& - notification name
337   ///
338   /// \param  [IN] f_pmessage
339   ///         PVOID - pointer to message
340   ///
341   /// \param  f_uimsgsize
342   ///         UI_32 - size of Message
343   ///
344   /// \return EFrameworkunifiedStatus
345   //          EFrameworkunifiedStatus - eFrameworkunifiedStatusOK on success
346   ///                      eFrameworkunifiedStatusInvldParam - invalid parameter
347   ///                      eFrameworkunifiedStatusNullPointer - if notification not found
348   ///
349   ////////////////////////////////////////////////////////////////////////////////////////////////
350   EFrameworkunifiedStatus NotificationpersistentservicePublishImmediateNotification(const std::string &f_cservicename,
351                                              const std::string &f_cnotificationname,
352                                              PVOID f_pmessage,
353                                              const UI_32 f_uimsgsize);
354
355 #ifdef NPP_PROFILEINFO_ENABLE
356
357   ////////////////////////////////////////////////////////////////////////////////////////////////
358   /// GetNotificationProfilingData
359   /// This function is used to get the notification profiling information.
360   ///
361   /// \param  [OUT] f_tNotificationProfileInfo
362   ///     std::string - all the notification info of all applications concated in a string
363   ///
364   /// \return EFrameworkunifiedStatus
365   //      EFrameworkunifiedStatus - success or failure status
366   ///
367   ////////////////////////////////////////////////////////////////////////////////////////////////
368   EFrameworkunifiedStatus GetNotificationProfilingData(std::string &f_cnotificationprofileInfo); // NOLINT (runtime/references)
369
370 #endif
371
372  private:
373   Notification_Type *m_pmNotificationList;      /// < map containing list of all notifications.
374
375   std::vector<std::string> *m_pvPersistentList;   /// < vector containing list of all persistent notifications.
376
377   std::vector<std::string> *m_pvUserPersistentList;   /// < vector containing list of all user persistent notifications.
378
379   ////////////////////////////////////////////////////////////////////////////////////////////////
380   /// CreateNotificationObject
381   /// This function is used to get notification object from map if it exists else create new
382   /// object as per type of notification.
383   ///
384   /// \param  [IN] f_cnotificationname
385   ///     std::string - notification name
386   ///
387   /// \param  [IN] f_uimsglength
388   ///     UI_32 - Maximum size of notification message
389   ///
390   /// \param  [IN] f_enotificationtype
391   ///     EFrameworkunifiedPersistentVarType - Delay time for persistence
392   ///
393   /// \param  [IN] f_uidelay
394   ///     UI_32 - Persistence Delay
395   ///
396   /// \return CNotification
397   //      CNotification - pointer of notification object
398   ///
399   ////////////////////////////////////////////////////////////////////////////////////////////////
400   CNotification *CreateNotificationObject(const std::string &f_cnotificationname,
401                                           const UI_32 f_uimsglength,
402                                           const EFrameworkunifiedNotificationType f_enotificationtype,
403                                           const UI_32 f_uidelay = 0);
404
405   ////////////////////////////////////////////////////////////////////////////////////////////////
406   /// SearchNotification
407   /// This function is used to search whether notification object is present in map or not.
408   /// If present it sends the reference.    CNotification - reference to pointer of notification object
409   ///
410   /// \param  [IN] f_cnotificationname
411   ///     std::string - notification name
412   ///
413   /// \return CNotification
414   //      CNotification - pointer of notification object
415   ///
416   ////////////////////////////////////////////////////////////////////////////////////////////////
417   CNotification *SearchNotification(const std::string &f_cnotificationname);
418
419   ////////////////////////////////////////////////////////////////////////////////////////////////
420   /// SearchPersistenceNotification
421   /// This function is used to search whether the given persistent notification object
422   /// is present in map or not.
423   ///
424   /// \param  [IN] f_cnotificationname
425   ///     std::string - notification name
426   ///
427   /// \return CStateNotification
428   //      CStateNotification - pointer of notification object
429   ///
430   ////////////////////////////////////////////////////////////////////////////////////////////////
431   CStateNotification *SearchPersistenceNotification(const std::string &f_cnotificationname);
432
433   ////////////////////////////////////////////////////////////////////////////////////////////////
434   /// CreateNotificationObjectToPersist
435   /// Creates the CNotificationsToPersist object from notification object and the persistent data.
436   ///
437   /// \param  [IN] f_pnotification
438   ///     CStateNotification - notification object ptr
439   /// \param  [IN] f_pdata
440   ///     CPersistentData - persistent data
441   ///
442   /// \return CNotification
443   //      CNotification - pointer of notification object
444   ///
445   ////////////////////////////////////////////////////////////////////////////////////////////////
446   CNotificationsToPersist *CreateNotificationObjectToPersist(CStateNotification *f_pnotification,
447                                                              const CPersistentData *f_pdata);
448
449   ////////////////////////////////////////////////////////////////////////////////////////////////
450   /// RemoveUserSpecificNotificationEntry
451   /// This function is used to get the singleton instance of class.
452   ///
453   /// \param
454   ///
455   /// \return EFrameworkunifiedStatus
456   ///     EFrameworkunifiedStatus - success or failure status
457   ///
458   ////////////////////////////////////////////////////////////////////////////////////////////////
459   EFrameworkunifiedStatus RemoveUserSpecificNotificationEntry();
460
461   ////////////////////////////////////////////////////////////////////////////////////////////////
462   /// ChangeNotificationType
463   /// This function creates new notification object depending on the type and replaces the old one.
464   /// The subscribers list is copied from the old notification object is copied to the new one.
465   ///
466   /// \param  [IN] f_pnotification
467   ///     CNotification* - old notification object
468   ///
469   /// \param  [IN] f_cservicename
470   ///     std::string - name of service registering for notification
471   ///
472   /// \param  [IN] f_cnotificationname
473   ///     std::string - notification name
474   ///
475   /// \param  [IN] f_uimsglength
476   ///     UI_32 - Maximum length of Message
477   ///
478   /// \param  [IN] f_enotificationtype
479   ///     EFrameworkunifiedPersistentVarType - new type of notification
480   ///
481   /// \param  [IN] f_uidelay
482   ///     UI_32 - Delay time for persistence
483   ///
484   /// \return EFrameworkunifiedStatus
485   //      EFrameworkunifiedStatus - success or failure status
486   ///
487   ////////////////////////////////////////////////////////////////////////////////////////////////
488   EFrameworkunifiedStatus ChangeNotificationType(CNotification *f_pnotification,
489                                     const std::string &f_cservicename,
490                                     const std::string &f_cnotificationname,
491                                     const UI_32 f_uimsglength,
492                                     const EFrameworkunifiedNotificationType f_enotificationtype,
493                                     const UI_32 f_uidelay);
494 };
495
496 #endif  // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_NOTIFICATION_MANAGER_H_