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 tag_NS_NPPService
19 /// \ingroup tag_NS_NPPService
21 //////////////////////////////////////////////////////////////////////////////////////////////////
23 //////////////////////////////////////////////////////////////////////////////////////////////////
24 /// \ingroup tag_NS_NPPService
25 /// \brief This class holds the message queue handles for notification subscribers
27 /// This is a singleton class which holds the message queue handles for notification subscribers.
28 /// This will ensure that NS_NPPService will hold only one handle per subscriber.
29 //////////////////////////////////////////////////////////////////////////////////////////////////
31 #ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_HANDLELIST_H_
32 #define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_HANDLELIST_H_
34 #include <native_service/frameworkunified_types.h>
39 typedef std::map<std::string, HANDLE> HandleList_Type;
40 typedef std::pair<HandleList_Type::iterator, bool> HandleListRetStatus_Type;
45 * This class holds the message queue handles for notification subscribers
49 ////////////////////////////////////////////////////////////////////////////////////////////////
51 /// This function is used to get the singleton instance of class.
52 /// NOTE: Not thread safe. Others threads would not use this function.
54 /// \return CHandleList
55 /// CHandleList - singleton instance of class
57 ////////////////////////////////////////////////////////////////////////////////////////////////
58 static CHandleList *GetHandleList();
60 ////////////////////////////////////////////////////////////////////////////////////////////////
62 /// This function is used to release the instance of class.
63 /// NOTE: Not thread safe. Others threads would not use this function.
67 /// \return EFrameworkunifiedStatus
68 // EFrameworkunifiedStatus - success or failure status
70 ////////////////////////////////////////////////////////////////////////////////////////////////
71 static EFrameworkunifiedStatus ReleaseHandleList();
73 ////////////////////////////////////////////////////////////////////////////////////////////////
75 /// Add pair of subscriber name and corresponding handle in map.
76 /// NOTE: Not thread safe. Others threads would not use this function.
78 /// \param [IN] f_csubscribername
79 /// std::string - name of application subscribing for notification
80 /// \param [IN] f_hmqhandle
81 /// HANDLE - Message queue handle of the subscriber
83 /// \return EFrameworkunifiedStatus
84 // EFrameworkunifiedStatus -
86 ////////////////////////////////////////////////////////////////////////////////////////////////
87 EFrameworkunifiedStatus AddHandleInList(std::string f_csubscribername, HANDLE f_hmqhandle);
89 ////////////////////////////////////////////////////////////////////////////////////////////////
90 /// RemoveHandleFromList
91 /// Remove handle for subscriber from the list.
92 /// Handle will actually get removed when all the notifications are unsubscribed by the subscriber
93 /// NOTE: Not thread safe. Others threads would not use this function.
95 /// \param [IN] f_csubscribername
96 /// std::string - name of application subscribing for notification
98 /// \return EFrameworkunifiedStatus
99 // EFrameworkunifiedStatus -
101 ////////////////////////////////////////////////////////////////////////////////////////////////
102 EFrameworkunifiedStatus RemoveHandleFromList(std::string f_csubscribername);
104 ////////////////////////////////////////////////////////////////////////////////////////////////
105 /// GetSubscriberMqHandle
106 /// Get the message queue handle of a subscriber.
107 /// NOTE: Not thread safe. Others threads would not use this function.
109 /// \param [IN] f_csubscribername
110 /// std::string - name of application subscribing for notification
113 // HANDLE - Message queue handle of the subscriber
115 ////////////////////////////////////////////////////////////////////////////////////////////////
116 HANDLE GetSubscriberMqHandle(std::string f_csubscribername);
119 ////////////////////////////////////////////////////////////////////////////////////////////////
121 /// Constructor of CHandleList class
127 ////////////////////////////////////////////////////////////////////////////////////////////////
130 ////////////////////////////////////////////////////////////////////////////////////////////////
132 /// Destructor of CHandleList class
138 ////////////////////////////////////////////////////////////////////////////////////////////////
141 HandleList_Type m_mHandleList; ///< map which stores all the message queue handle
143 static CHandleList *m_psHandleList; // NOLINT (readability/naming)
145 #endif // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_HANDLELIST_H_