Updated Topic resource changes for C++ wrapper
[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 #include "NSUtils.h"\r
35 #include "NSTopicsList.h"\r
36 \r
37 namespace OIC\r
38 {\r
39     namespace Service\r
40     {\r
41         /**\r
42          * @class   NSProvider\r
43          * @brief   This class provides a set of Notification service Provider representation APIs.\r
44          */\r
45         class NSProvider\r
46         {\r
47             public:\r
48                 /**\r
49                      * Consumer use this callback function to receive notification message from provider\r
50                      * synchronization\r
51                      * @param[in] message     Notification message\r
52                      */\r
53                 typedef void (*MessageReceivedCallback)(NSMessage *);\r
54 \r
55                 /**\r
56                      * Provider and consumer use this callback function to receive the status of the message\r
57                      * synchronization\r
58                      * @param[in] sync        Synchronization information of the notification message\r
59                      */\r
60                 typedef void (*SyncInfoReceivedCallback)(NSSyncInfo *);\r
61 \r
62                 /**\r
63                       * Constructor of NSProvider.\r
64                       */\r
65                 NSProvider(): m_topicList(new NSTopicsList()), m_messageCb(NULL), m_syncInfoCb(NULL) {}\r
66 \r
67                 /**\r
68                       * Constructor of NSProvider.\r
69                       *\r
70                       * @param providerId - providerId of the Notification.\r
71                       */\r
72                 NSProvider(const std::string &providerId) : m_providerId(providerId),\r
73                     m_topicList(new NSTopicsList()), m_messageCb(NULL), m_syncInfoCb(NULL) {}\r
74 \r
75                 /**\r
76                       * Constructor of NSProvider.\r
77                       *\r
78                       * @param providerId - providerId of the Notification.\r
79                       * @param topicList - NSTopicsList of interested Topics.\r
80                       */\r
81                 NSProvider(const std::string &providerId, NSTopicsList *topicList) : m_providerId(\r
82                         providerId), m_topicList(topicList), m_messageCb(NULL), m_syncInfoCb(NULL) {}\r
83 \r
84                 /**\r
85                       * Constructor of NSProvider.\r
86                       *\r
87                       * @param provider - of type NSProvider.\r
88                       */\r
89                 NSProvider(::NSProvider *provider);\r
90 \r
91 \r
92                 /**\r
93                       * Destructor of NSProvider.\r
94                       */\r
95                 ~NSProvider();\r
96 \r
97                 /**\r
98                       * This method is for getting ProviderId from the Notification service provider.\r
99                       *\r
100                       * @return ProviderId as string.\r
101                       */\r
102                 std::string getProviderId() const;\r
103 \r
104                 /**\r
105                       * This method is for getting NSTopic List from the Notification service provider.\r
106                       *\r
107                       * @return NSTopicsList  as pointer.\r
108                       */\r
109                 NSTopicsList *getTopicList() const;\r
110 \r
111                 /**\r
112                       * This method is for requesting subscription of Notification service.\r
113                       *\r
114                       */\r
115                 void subscribe();\r
116 \r
117                 /**\r
118                       * This method is for requesting unsubscription of Notification service.\r
119                       *\r
120                       */\r
121                 void unSubscribe();\r
122 \r
123                 /**\r
124                       * This method is for Sending SyncInfo of Notification service.\r
125                       *\r
126                       * @param messageId - id of type message.\r
127                       * @param type - NSSyncType of Notification service.\r
128                       */\r
129                 void SendSyncInfo(uint64_t messageId, NSSyncInfo::NSSyncType type);\r
130 \r
131                 /**\r
132                       * This method is for registering for listeners of Notification .\r
133                       *\r
134                       * @param messageHandle - MessageReceivedCallback callback.\r
135                       * @param syncHandle - SyncInfoReceivedCallback callback\r
136                       */\r
137                 void setListener(MessageReceivedCallback messageHandle,\r
138                                  SyncInfoReceivedCallback syncHandle);\r
139 \r
140                 /**\r
141                      * Select Topic list that is wanted to subscribe from provider\r
142                      *\r
143                      * @param topicList - NSTopicsList of interested Topics.\r
144                      * @return NSResult\r
145                      */\r
146                 NSResult selectInterestTopics(NSTopicsList *topicList);\r
147 \r
148                 /**\r
149                       * This method is for getting the registered cb of Notification message received.\r
150                       *\r
151                       * @return messageCb - MessageReceivedCallback .\r
152                       */\r
153                 MessageReceivedCallback getMessageReceivedCb();\r
154 \r
155                 /**\r
156                       * This method is for getting the registered cb of Notification SyncInfo received.\r
157                       *\r
158                       * @return syncInfoCb - SyncInfoReceivedCallback .\r
159                       */\r
160                 SyncInfoReceivedCallback getSyncInfoReceivedCb();\r
161 \r
162             private:\r
163                 ::NSProvider *getNSProvider();\r
164 \r
165             private:\r
166                 std::string m_providerId;\r
167                 NSTopicsList *m_topicList;\r
168                 MessageReceivedCallback m_messageCb;\r
169                 SyncInfoReceivedCallback m_syncInfoCb;\r
170 \r
171         };\r
172     }\r
173 }\r
174 #endif /* _NS_PROVIDER_H_ */\r