Merge branch 'master' into notification-service
[platform/upstream/iotivity.git] / service / notification / cpp-wrapper / consumer / inc / NSProvider.h
1 //******************************************************************\r
2 //\r
3 // Copyright 2016 Samsung Electronics All Rights Reserved.\r
4 //\r
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
6 //\r
7 // Licensed under the Apache License, Version 2.0 (the "License");\r
8 // you may not use this file except in compliance with the License.\r
9 // You may obtain a copy of the License at\r
10 //\r
11 //      http://www.apache.org/licenses/LICENSE-2.0\r
12 //\r
13 // Unless required by applicable law or agreed to in writing, software\r
14 // distributed under the License is distributed on an "AS IS" BASIS,\r
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16 // See the License for the specific language governing permissions and\r
17 // limitations under the License.\r
18 //\r
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
20 \r
21 /**\r
22  * @file\r
23  *\r
24  * This file contains Notification service Provider representation.\r
25  */\r
26 \r
27 #ifndef _NS_PROVIDER_H_\r
28 #define _NS_PROVIDER_H_\r
29 \r
30 \r
31 #include <string>\r
32 #include "NSSyncInfo.h"\r
33 #include "NSMessage.h"\r
34 \r
35 namespace OIC\r
36 {\r
37     namespace Service\r
38     {\r
39         /**\r
40          * @class   NSProvider\r
41          * @brief   This class provides a set of Notification service Provider representation APIs.\r
42          */\r
43         class NSProvider\r
44         {\r
45             public:\r
46                 /**\r
47                      * Consumer use this callback function to receive notification message from provider\r
48                      * synchronization\r
49                      * @param[in] message     Notification message\r
50                      */\r
51                 typedef void (*MessageReceivedCallback)(NSMessage *);\r
52 \r
53                 /**\r
54                      * Provider and consumer use this callback function to receive the status of the message\r
55                      * synchronization\r
56                      * @param[in] sync        Synchronization information of the notification message\r
57                      */\r
58                 typedef void (*SyncInfoReceivedCallback)(NSSyncInfo *);\r
59 \r
60                 /**\r
61                       * Constructor of NSProvider.\r
62                       */\r
63                 NSProvider(): m_messageCb(NULL), m_syncInfoCb(NULL) {}\r
64 \r
65                 /**\r
66                       * Constructor of NSProvider.\r
67                       *\r
68                       * @param providerId - providerId of the Notification.\r
69                       */\r
70                 NSProvider(const std::string &providerId) : m_providerId(providerId),\r
71                     m_messageCb(NULL), m_syncInfoCb(NULL) {}\r
72 \r
73                 /**\r
74                       * Constructor of NSProvider.\r
75                       *\r
76                       * @param provider - of type NSProvider.\r
77                       */\r
78                 NSProvider(::NSProvider *provider);\r
79 \r
80 \r
81                 /**\r
82                       * Destructor of NSProvider.\r
83                       */\r
84                 ~NSProvider() = default;\r
85 \r
86                 /**\r
87                       * This method is for getting ProviderId from the Notification service provider.\r
88                       *\r
89                       * @return ProviderId as string.\r
90                       */\r
91                 std::string getProviderId() const;\r
92 \r
93                 /**\r
94                       * This method is for requesting subscription of Notification service.\r
95                       *\r
96                       */\r
97                 void subscribe();\r
98 \r
99                 /**\r
100                       * This method is for requesting unsubscription of Notification service.\r
101                       *\r
102                       */\r
103                 void unSubscribe();\r
104 \r
105                 /**\r
106                       * This method is for Sending SyncInfo of Notification service.\r
107                       *\r
108                       * @param messageId - id of type message.\r
109                       * @param type - NSSyncType of Notification service.\r
110                       */\r
111                 void SendSyncInfo(uint64_t messageId, NSSyncInfo::NSSyncType type);\r
112 \r
113                 /**\r
114                       * This method is for registering for listeners of Notification .\r
115                       *\r
116                       * @param messageHandle - MessageReceivedCallback callback.\r
117                       * @param syncHandle - SyncInfoReceivedCallback callback\r
118                       */\r
119                 void setListener(MessageReceivedCallback messageHandle,\r
120                                  SyncInfoReceivedCallback syncHandle);\r
121 \r
122                 /**\r
123                       * This method is for getting the registered cb of Notification message received.\r
124                       *\r
125                       * @return messageCb - MessageReceivedCallback .\r
126                       */\r
127                 MessageReceivedCallback getMessageReceivedCb();\r
128 \r
129                 /**\r
130                       * This method is for getting the registered cb of Notification SyncInfo received.\r
131                       *\r
132                       * @return syncInfoCb - SyncInfoReceivedCallback .\r
133                       */\r
134                 SyncInfoReceivedCallback getSyncInfoReceivedCb();\r
135 \r
136             private:\r
137                 ::NSProvider *getNSProvider();\r
138 \r
139             private:\r
140                 std::string m_providerId;\r
141                 MessageReceivedCallback m_messageCb;\r
142                 SyncInfoReceivedCallback m_syncInfoCb;\r
143 \r
144         };\r
145     }\r
146 }\r
147 #endif /* _NS_PROVIDER_H_ */\r