IoTivity C++ SDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
NSConsumerService.h
Go to the documentation of this file.
1 //******************************************************************
2 //
3 // Copyright 2016 Samsung Electronics All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 // http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20 
21 
28 #ifndef _NS_CONSUMER_SERVICE_H_
29 #define _NS_CONSUMER_SERVICE_H_
30 
31 #include <algorithm>
32 #include "NSProvider.h"
33 #include "NSUtils.h"
34 
35 
36 namespace OIC
37 {
38  namespace Service
39  {
40  class NSAcceptedProviders;
46  {
47  public :
52  typedef void (*ProviderDiscoveredCallback)(std::shared_ptr<NSProvider> );
53 
60 
66  NSResult start(ProviderDiscoveredCallback providerDiscovered);
67 
72  NSResult stop();
73 
79  NSResult enableRemoteService(const std::string &serverAddress);
80 
87  NSResult subscribeMQService(const std::string &serverAddress, const std::string &topicName);
88 
94 
100 
107  std::shared_ptr<NSProvider> getProvider(const std::string &id);
108 
114 
115  private :
116  ProviderDiscoveredCallback m_providerDiscoveredCb;
117  NSAcceptedProviders *m_acceptedProviders;
118 
119  private :
122  NSConsumerService(const NSConsumerService & ) = delete;
123  NSConsumerService &operator=(const NSConsumerService & ) = delete;
124  NSConsumerService(const NSConsumerService &&) = delete;
125  NSConsumerService &operator=(const NSConsumerService && ) = delete;
126 
127  static void onProviderStateReceived(::NSProvider *provider, ::NSProviderState state);
128  static void onNSMessageReceived(::NSMessage *message);
129  static void onNSSyncInfoReceived(::NSSyncInfo *syncInfo);
130 
131  };
132  }
133 }
134 
135 #endif //_NS_CONSUMER_SERVICE_H_
NSResult start(ProviderDiscoveredCallback providerDiscovered)
Initialize notification service for consumer.
This file contains Notification service Utils.
This class provides a set of Notification service Provider representation APIs.
Definition: NSProvider.h:46
This class provides a set of C++APIs for Notification Consumer.
Definition: NSConsumerService.h:45
static NSConsumerService * getInstance()
API for getting the Instance of NSConsumerService class.
This class provides a set of C++APIs for managing accepted Providers.
Definition: NSAcceptedProviders.h:45
NSResult
NSResult - enumeration for NS service Result.
Definition: NSUtils.h:38
NSResult enableRemoteService(const std::string &serverAddress)
Request to discover to remote address as parameter.
NSAcceptedProviders * getAcceptedProviders()
get handle of providers accepted.
This class provides a set of APIs for Notification service Message .
Definition: NSMessage.h:42
void(* ProviderDiscoveredCallback)(std::shared_ptr< NSProvider >)
Consumer uses this callback function to receive the discovered providers.
Definition: NSConsumerService.h:52
NSResult stop()
Terminate notification service for consumer.
This file contains Notification service Provider representation.
ProviderDiscoveredCallback getProviderDiscoveredCb()
get the callback for ProviderDiscovered
NSResult subscribeMQService(const std::string &serverAddress, const std::string &topicName)
Request to subscribe to remote MQ address as parameter.
NSProviderState
NSProviderState of notification service.
Definition: NSUtils.h:49
This class provides a set of APIs for Notification service SyncInfo .
Definition: NSSyncInfo.h:41
std::shared_ptr< NSProvider > getProvider(const std::string &id)
request to get NSProvider pointer
NSResult rescanProvider()
Request discovery manually.