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 contains declaration of class CNotification.
27 ////////////////////////////////////////////////////////////////////////////////////////////////////
29 #ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_NOTIFICATION_H_
30 #define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_NOTIFICATION_H_
32 ////////////////////////////////////////////////////////////////////////////////////////////////////
34 ////////////////////////////////////////////////////////////////////////////////////////////////////
35 #include <native_service/frameworkunified_types.h>
39 #include "ns_npp_notification_receiver.h"
41 typedef std::map<std::string, CNotificationReceiver *> NotifReceiver_Type;
43 /// Iterator of map of CNotificationReceiver
44 typedef NotifReceiver_Type::iterator NotifReceiver_Iterator_Type;
47 * This class is base class for all the notification types classes.
51 ////////////////////////////////////////////////////////////////////////////////////////////////
53 /// Parameterless Constructor of CNotification class
59 ////////////////////////////////////////////////////////////////////////////////////////////////
63 std::string m_cNotificationName; ///< Name of Notification
65 UI_32 m_uiMaxMsgSize; ///< Maximum size of notification data
67 EFrameworkunifiedNotificationType m_ePersistentType; ///< type of notification
69 std::string m_cServiceName; ///< List of services registering notification
71 NotifReceiver_Type *m_pmSubscribersList; ///< list of subscribers of notification
73 ////////////////////////////////////////////////////////////////////////////////////////////////
75 /// This function adds the name of the service to receiver list of notification.
77 /// \param [IN] f_csubscribername
78 /// std::string - name of application subscribing for notification
80 /// \return EFrameworkunifiedStatus
81 // EFrameworkunifiedStatus - success or failure status
83 ////////////////////////////////////////////////////////////////////////////////////////////////
84 EFrameworkunifiedStatus AddReceiverInMap(const std::string &f_csubscribername);
86 ////////////////////////////////////////////////////////////////////////////////////////////////
88 /// This function publishes the notification to subscribed clients.
90 /// \param [IN] f_hmsgqhandle
91 /// HANDLE - MessageQ Handle of ReceiverQ
93 /// \param [IN] f_pmessage
94 /// std::string - data of notification
96 /// \param [IN] f_uimsgsize
97 /// std::string - length of data
99 /// \return EFrameworkunifiedStatus
100 // EFrameworkunifiedStatus - success or failure status
102 ////////////////////////////////////////////////////////////////////////////////////////////////
103 EFrameworkunifiedStatus PublishData(HANDLE f_hmsgqhandle,
104 const PVOID f_pmessage,
105 const UI_32 f_uimsgsize);
108 ////////////////////////////////////////////////////////////////////////////////////////////////
110 /// Constructor of CNotification class
112 /// \param [IN] f_cnotificationname
113 /// std::string - Notification name
115 /// \param [IN] f_uimaxmsgsize
116 /// UI_32 - Maximum size of notification data
120 ////////////////////////////////////////////////////////////////////////////////////////////////
121 CNotification(const std::string &f_cnotificationname,
122 const UI_32 f_uimaxmsgsize);
124 ////////////////////////////////////////////////////////////////////////////////////////////////
126 /// Destructor of CNotification class
132 ////////////////////////////////////////////////////////////////////////////////////////////////
133 virtual ~CNotification();
135 ////////////////////////////////////////////////////////////////////////////////////////////////
137 /// This function adds the name of the application to receiver list of particular notification.
139 /// \param [IN] f_csubscribername
140 /// std::string - name of application subscribing for notification
142 /// \return EFrameworkunifiedStatus
143 // EFrameworkunifiedStatus - success or failure status
145 ////////////////////////////////////////////////////////////////////////////////////////////////
146 virtual EFrameworkunifiedStatus AddEventReciever(const std::string &f_csubscribername);
148 ////////////////////////////////////////////////////////////////////////////////////////////////
150 /// This function publishes the notification to subscribed clients.
152 /// \param [IN] f_cservicename
153 /// std::string - name of service publishing the notification
155 /// \param [IN] f_pmessage
156 /// std::string - data of notification
158 /// \param [IN] f_uimsgsize
159 /// std::string - length of data
161 /// \return EFrameworkunifiedStatus
162 // EFrameworkunifiedStatus - success or failure status
164 ////////////////////////////////////////////////////////////////////////////////////////////////
165 virtual EFrameworkunifiedStatus Publish(const std::string &f_cservicename,
167 const UI_32 f_uimsgsize);
169 ////////////////////////////////////////////////////////////////////////////////////////////////
170 /// DeleteEventReciever
171 /// This function deletes the name of application from receivers list.
173 /// \param [IN] f_csubscribername
174 /// std::string - name of application
176 /// \return EFrameworkunifiedStatus
177 // EFrameworkunifiedStatus - success or failure status
179 ////////////////////////////////////////////////////////////////////////////////////////////////
180 EFrameworkunifiedStatus DeleteEventReciever(const std::string &f_csubscribername);
182 ////////////////////////////////////////////////////////////////////////////////////////////////
183 /// SetNewSubscribersList
184 /// This function sets the subscribers list of notification
186 /// \param [IN] f_pnotification
187 /// CNotification - notification object containing subscribers list
189 /// \return EFrameworkunifiedStatus
190 // EFrameworkunifiedStatus - success or failure status
192 ////////////////////////////////////////////////////////////////////////////////////////////////
193 EFrameworkunifiedStatus SetNewSubscribersList(CNotification *f_pnotification);
195 ////////////////////////////////////////////////////////////////////////////////////////////////
196 /// SetEventPublisher
197 /// This function set the publisher name to current received service name
199 /// \param [IN] f_cservicename
200 /// std::string - name of application
202 /// \return EFrameworkunifiedStatus
203 // EFrameworkunifiedStatus - success or failure status
205 ////////////////////////////////////////////////////////////////////////////////////////////////
206 EFrameworkunifiedStatus SetEventPublisher(const std::string &f_cservicename);
208 ////////////////////////////////////////////////////////////////////////////////////////////////
209 /// ResetEventPublisher
210 /// This function resets the publisher name to NULL
212 /// \param [IN] f_cservicename
213 /// std::string - name of application
215 /// \return EFrameworkunifiedStatus
216 // EFrameworkunifiedStatus - success or failure status
218 ////////////////////////////////////////////////////////////////////////////////////////////////
219 EFrameworkunifiedStatus ResetEventPublisher(const std::string &f_cservicename);
221 ////////////////////////////////////////////////////////////////////////////////////////////////
222 /// IsServiceRegistered
223 /// This function checks whether the notification is registered with any service or not.
228 // BOOL - true,if subscriber list is empty
230 ////////////////////////////////////////////////////////////////////////////////////////////////
231 BOOL IsServiceRegistered();
233 ////////////////////////////////////////////////////////////////////////////////////////////////
234 /// IsSubscribersListEmpty
235 /// This function is used to check whether any service is subscribed to notification
240 // BOOL - true,if subscriber list is empty
242 ////////////////////////////////////////////////////////////////////////////////////////////////
243 BOOL IsSubscribersListEmpty();
245 ////////////////////////////////////////////////////////////////////////////////////////////////
246 /// GetNotificationName
247 /// This function is used to get the notification name.
251 /// \return std::string
252 // std::string - notification name
254 ////////////////////////////////////////////////////////////////////////////////////////////////
255 std::string GetNotificationName();
257 ////////////////////////////////////////////////////////////////////////////////////////////////
259 /// This function is used to get the publisher name of notification.
263 /// \return std::string
264 // std::string - service name
266 ////////////////////////////////////////////////////////////////////////////////////////////////
267 std::string GetPublisherName();
269 ////////////////////////////////////////////////////////////////////////////////////////////////
270 /// GetPersistenceType
271 /// This function is used to get the type of notification.
275 /// \return EFrameworkunifiedPersistentVarType
276 // EFrameworkunifiedPersistentVarType - persistent type
278 ////////////////////////////////////////////////////////////////////////////////////////////////
279 EFrameworkunifiedNotificationType GetNotificationType();
281 ////////////////////////////////////////////////////////////////////////////////////////////////
282 /// GetMaxMessageSize
283 /// This function is used to get the max size of data of notification message.
288 // UI_32 - Max Message Size
290 ////////////////////////////////////////////////////////////////////////////////////////////////
291 UI_32 GetMaxMessageSize();
293 ////////////////////////////////////////////////////////////////////////////////////////////////
294 /// ResetMaxMessageSize
295 /// This function reset the max size of data that can be published with notification
297 /// \param [IN] f_uilength
298 /// std::string - Max size for notification data
300 /// \return EFrameworkunifiedStatus
301 // EFrameworkunifiedStatus - success or failure status
303 ////////////////////////////////////////////////////////////////////////////////////////////////
304 virtual EFrameworkunifiedStatus ResetMaxMessageSize(const UI_32 f_uilength);
306 #ifdef NPP_PROFILEINFO_ENABLE
308 ////////////////////////////////////////////////////////////////////////////////////////////////
309 /// GetSubscriberList
310 /// Returns the list of subscribers subscribed to notification
314 /// \return NotifReceiver_Type
315 // NotifReceiver_Type - subscriber's list of notification
317 ////////////////////////////////////////////////////////////////////////////////////////////////
318 NotifReceiver_Type *GetSubscriberList();
323 #endif // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_NOTIFICATION_H_