1 //******************************************************************
\r
3 // Copyright 2016 Samsung Electronics All Rights Reserved.
\r
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
\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
11 // http://www.apache.org/licenses/LICENSE-2.0
\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
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
\r
25 * This file provides C++ Wrapper APIs of Notification Service for Consumer.
\r
28 #ifndef _NS_CONSUMER_SERVICE_H_
\r
29 #define _NS_CONSUMER_SERVICE_H_
\r
31 #include "NSCommon.h"
\r
32 #include "NSConsumerInterface.h"
\r
34 #include <algorithm>
\r
35 #include "NSConstants.h"
\r
44 * @class NSConsumerService
\r
45 * @brief This class provides a set of C++APIs for Notification Consumer.
\r
47 class NSConsumerService
\r
52 * Consumer uses this callback function to receive the discovered providers
\r
53 * @param[in] provider Provider who has the notification resource
\r
55 typedef void (*ProviderDiscoveredCallback)(NSProvider *);
\r
58 * Consumer uses this callback function on subscription accepted by provider
\r
59 * @param[in] provider Provider who has the notification resource
\r
61 typedef void (* AcceptedCallback)(NSProvider *);
\r
64 * @struct ConsumerConfig
\r
65 * @brief Consumer sets this callback function configuration for registering callbacks
\r
70 /** m_discoverCb - ProviderDiscoveredCallback callback listener.*/
\r
71 ProviderDiscoveredCallback m_discoverCb;
\r
72 /** m_acceptedCb - AcceptedCallback callback listener.*/
\r
73 AcceptedCallback m_acceptedCb;
\r
77 * API for getting the Instance of NSConsumerService class
\r
79 * @return Instance of the "NSConsumerService" class
\r
81 static NSConsumerService *getInstance();
\r
84 * Initialize notification service for consumer
\r
85 * @param[in] config ConsumerConfig Callback function pointers to onDiscoverd,
\r
86 * OnAccepted, OnMessageReceived and OnSyncInfoReceived functions
\r
88 void Start(ConsumerConfig config);
\r
91 * Terminate notification service for consumer
\r
96 * Request to discover to remote address as parameter.
\r
97 * @param[in] server address combined with IP address and port number using delimiter :
\r
98 * @return result code of NSResult
\r
100 NSResult EnableRemoteService(const std::string &serverAddress);
\r
103 * Request discovery manually
\r
105 void RescanProvider();
\r
108 * request to get NSProvider pointer
\r
109 * @param id -id as string
\r
111 * @return pointer to NSProvider
\r
113 NSProvider *getProvider(const std::string &id);
\r
116 * get consumer config values
\r
117 * @return ConsumerConfig callbaks set
\r
119 ConsumerConfig getConsumerConfig();
\r
122 * get list of providers acceted.
\r
123 * @return m_acceptedProviders -list of accepted providers
\r
125 std::list<NSProvider *> getAcceptedProviders();
\r
128 ConsumerConfig m_config;
\r
129 std::list<NSProvider *> m_acceptedProviders;
\r
132 NSConsumerService();
\r
133 ~NSConsumerService();
\r
134 NSConsumerService(const NSConsumerService & ) = delete;
\r
135 NSConsumerService &operator=(const NSConsumerService & ) = delete;
\r
136 NSConsumerService(const NSConsumerService &&) = delete;
\r
137 NSConsumerService &operator=(const NSConsumerService && ) = delete;
\r
143 #endif //_NS_CONSUMER_SERVICE_H_
\r