Use `URI` all caps in documentation
[iotivity.git] / service / notification / cpp-wrapper / consumer / inc / NSConsumerService.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 /**\r
23  * @file\r
24  *\r
25  * This file provides C++ Wrapper APIs of Notification Service for Consumer.\r
26  */\r
27 \r
28 #ifndef _NS_CONSUMER_SERVICE_H_\r
29 #define _NS_CONSUMER_SERVICE_H_\r
30 \r
31 #include <algorithm>\r
32 #include "NSProvider.h"\r
33 #include "NSUtils.h"\r
34 \r
35 \r
36 namespace OIC\r
37 {\r
38     namespace Service\r
39     {\r
40         class NSAcceptedProviders;\r
41         /**\r
42          * @class   NSConsumerService\r
43          * @brief   This class provides a set of C++APIs for Notification Consumer.\r
44          */\r
45         class NSConsumerService\r
46         {\r
47             public :\r
48                 /**\r
49                      * Consumer uses this callback function to receive the discovered providers\r
50                      * @param[in] provider        Provider who has the notification resource\r
51                      */\r
52                 typedef void (*ProviderDiscoveredCallback)(std::shared_ptr<NSProvider> );\r
53 \r
54                 /**\r
55                       * API for getting the Instance of NSConsumerService class\r
56                       *\r
57                       * @return Instance of the "NSConsumerService" class\r
58                       */\r
59                 static NSConsumerService *getInstance();\r
60 \r
61                 /**\r
62                       * Initialize notification service for consumer\r
63                       * @param providerDiscovered Callback function pointers to ProviderDiscoveredCallback,\r
64                       * @return ::NS_OK or result code of NSResult\r
65                       */\r
66                 NSResult start(ProviderDiscoveredCallback providerDiscovered);\r
67 \r
68                 /**\r
69                       * Terminate notification service for consumer\r
70                       * @return ::NS_OK or result code of NSResult\r
71                       */\r
72                 NSResult stop();\r
73 \r
74                 /**\r
75                      * Request to discover to remote address as parameter.\r
76                      * @param[in]  serverAddress combined with IP address and port number using delimiter :\r
77                      * @return  NSResult code of Consumer Service\r
78                      */\r
79                 NSResult enableRemoteService(const std::string &serverAddress);\r
80 \r
81                 /**\r
82                       * Request to subscribe to remote MQ address as parameter.\r
83                       * @param[in] serverAddress server address combined with IP address and port number and MQ broker URI using delimiter :\r
84                       * @param[in] topicName the interest Topic name for subscription.\r
85                       * @return ::NS_OK or result code of NSResult\r
86                       */\r
87                 NSResult subscribeMQService(const std::string &serverAddress, const std::string &topicName);\r
88 \r
89                 /**\r
90                       * Request discovery manually\r
91                       * @return ::NS_OK or result code of NSResult\r
92                       */\r
93                 NSResult rescanProvider();\r
94 \r
95                 /**\r
96                       *  get the callback for ProviderDiscovered\r
97                       * @return ProviderDiscoveredCallback callbak set\r
98                       */\r
99                 ProviderDiscoveredCallback getProviderDiscoveredCb();\r
100 \r
101                 /**\r
102                      *  request to get NSProvider pointer\r
103                      * @param id -id as string\r
104                      *\r
105                      * @return shared pointer to NSProvider\r
106                      */\r
107                 std::shared_ptr<NSProvider> getProvider(const std::string &id);\r
108 \r
109                 /**\r
110                       *  get handle of providers accepted.\r
111                       * @return m_acceptedProviders -accepted providers\r
112                       */\r
113                 NSAcceptedProviders *getAcceptedProviders();\r
114 \r
115             private :\r
116                 ProviderDiscoveredCallback m_providerDiscoveredCb;\r
117                 NSAcceptedProviders *m_acceptedProviders;\r
118 \r
119             private :\r
120                 NSConsumerService();\r
121                 ~NSConsumerService();\r
122                 NSConsumerService(const NSConsumerService & ) = delete;\r
123                 NSConsumerService &operator=(const NSConsumerService & ) = delete;\r
124                 NSConsumerService(const NSConsumerService &&) = delete;\r
125                 NSConsumerService &operator=(const NSConsumerService && ) = delete;\r
126 \r
127                 static void onProviderStateReceived(::NSProvider *provider, ::NSProviderState state);\r
128                 static void onNSMessageReceived(::NSMessage *message);\r
129                 static void onNSSyncInfoReceived(::NSSyncInfo *syncInfo);\r
130 \r
131         };\r
132     }\r
133 }\r
134 \r
135 #endif //_NS_CONSUMER_SERVICE_H_\r