Init basesystem source codes.
[staging/basesystem.git] / nsframework / notification_persistent_service / server / include / ns_npp_state_nor_persistence_notification.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 class CStateNorPersistenceNotification.
26 ///
27 ////////////////////////////////////////////////////////////////////////////////////////////////////
28
29 #ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_STATE_NOR_PERSISTENCE_NOTIFICATION_H_
30 #define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_STATE_NOR_PERSISTENCE_NOTIFICATION_H_
31
32 ////////////////////////////////////////////////////////////////////////////////////////////////////
33 // Include Files
34 ////////////////////////////////////////////////////////////////////////////////////////////////////
35 #include <string>
36 #include "ns_npp_state_notification.h"
37
38 /**
39  *  This class inherits CStateNotification class and implements specific operations related to
40  *  nor persistent notifications.
41  */
42 class CStateNorPersistenceNotification : public CStateNotification {
43  public:
44   ////////////////////////////////////////////////////////////////////////////////////////////////
45   /// CStateNorPersistenceNotification
46   /// Constructor of CStateNorPersistenceNotification class
47   ///
48   /// \param  [IN] f_cnotificationname
49   ///     std::string - Notification name
50   ///
51   /// \param  [IN] f_uimaxmsgsize
52   ///     UI_32 - Maximum size of notification data
53   ///
54   /// \param  [IN] f_uidelay
55   ///     UI_32 - delay
56   ///
57   /// \param  [IN] f_epersistcategory
58   ///     EFrameworkunifiedPersistCategory - persist category
59   ///
60   ////////////////////////////////////////////////////////////////////////////////////////////////
61   CStateNorPersistenceNotification(const std::string &f_cnotificationname,
62                                    const UI_32 f_uimaxmsgsize,
63                                    const UI_32 f_uidelay,
64                                    const EFrameworkunifiedPersistCategory f_epersistcategory = eFrameworkunifiedUserData);
65
66   ////////////////////////////////////////////////////////////////////////////////////////////////
67   /// ~CStateNorPersistenceNotification
68   /// Destructor of CStateNorPersistenceNotification class
69   ///
70   ////////////////////////////////////////////////////////////////////////////////////////////////
71   ~CStateNorPersistenceNotification();
72
73   ////////////////////////////////////////////////////////////////////////////////////////////////
74   /// GetPersistenceDelay
75   /// Method to get the persistence delay for a specific notification.
76   ///
77   /// \param
78   ///
79   /// \return UI_32
80   //      UI_32 - success or failure status
81   ///
82   ////////////////////////////////////////////////////////////////////////////////////////////////
83   UI_32 GetPersistenceDelay();
84
85   ////////////////////////////////////////////////////////////////////////////////////////////////
86   /// Publish
87   /// This function publishes the notification to subscribed clients and saves the data
88   /// immediately to persistent memory.
89   ///
90   /// \param  [IN] f_cservicename
91   ///     std::string - name of service publishing the notification
92   ///
93   /// \param  [IN] f_pmessage
94   ///     std::string - data of notification
95   ///
96   /// \param  [IN] f_uimsgsize
97   ///     std::string - length of data
98   ///
99   /// \return EFrameworkunifiedStatus
100   //      EFrameworkunifiedStatus - success or failure status
101   ///
102   ////////////////////////////////////////////////////////////////////////////////////////////////
103   virtual EFrameworkunifiedStatus Publish(const std::string &f_cservicename,
104                              PVOID f_pmessage,
105                              const UI_32 f_uimsgsize);
106
107   ////////////////////////////////////////////////////////////////////////////////////////////////
108   /// PublishNotification
109   /// This function publishes the notification to subscribed clients.
110   ///
111   /// \param  [IN] f_cservicename
112   ///         std::string - name of service publishing the notification
113   ///
114   /// \param  [IN] f_pmessage
115   ///         std::string - data of notification
116   ///
117   /// \param  [IN] f_uimsgsize
118   ///         std::string - length of data
119   ///
120   /// \return EFrameworkunifiedStatus
121   //          EFrameworkunifiedStatus - success or failure status
122   ///
123   ////////////////////////////////////////////////////////////////////////////////////////////////
124   EFrameworkunifiedStatus PublishNotification(const std::string &f_cservicename,
125                                  PVOID f_pmessage,
126                                  const UI_32 f_uimsgsize);
127
128   ////////////////////////////////////////////////////////////////////////////////////////////////
129   /// GetPersistentCategory
130   /// Gets the persist type of notification
131   ///
132   ///
133   /// \return EFrameworkunifiedPersistCategory
134   //      EFrameworkunifiedPersistCategory - persist type
135   ///
136   ////////////////////////////////////////////////////////////////////////////////////////////////
137   EFrameworkunifiedPersistCategory GetPersistentCategory();
138
139   ////////////////////////////////////////////////////////////////////////////////////////////////
140   /// SetPersistentCategory
141   /// Sets the persist type of notification
142   ///
143   /// \param  [IN] f_epersistcategory
144   ///     EFrameworkunifiedPersistCategory - persist category
145   ///
146   /// \return EFrameworkunifiedStatus
147   //      EFrameworkunifiedStatus - success or failure status
148   ///
149   ////////////////////////////////////////////////////////////////////////////////////////////////
150   EFrameworkunifiedStatus SetPersistentCategory(const EFrameworkunifiedPersistCategory f_epersistcategory);
151   // Handle of the immediate persistence worker thread.
152   static HANDLE m_hNSImmediatePersistenceThread;  // NOLINT (readability/naming)
153
154  private:
155   ////////////////////////////////////////////////////////////////////////////////////////////////
156   /// SaveDataToNor
157   /// Saves the persistent data to nor
158   ///
159   /// \param  [IN] f_pmessage
160   ///     PVOID - Message data
161   ///
162   /// \param  [IN] f_msgsize
163   ///     UI_32 - Size of Message data
164   ///
165   /// \return EFrameworkunifiedStatus
166   //      EFrameworkunifiedStatus - success or failure status
167   ///
168   ////////////////////////////////////////////////////////////////////////////////////////////////
169   EFrameworkunifiedStatus SaveDataToNor(PVOID f_pmessage,
170                            const UI_32 f_msgsize);
171
172   UI_32 m_uiDelay;  // Time Delay between persistence on NOR
173
174   EFrameworkunifiedPersistCategory m_ePersistCategory;  // Persistent category
175 };
176
177 #endif  // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_STATE_NOR_PERSISTENCE_NOTIFICATION_H_