replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / service / notification / cpp-wrapper / consumer / inc / NSAcceptedProviders.h
1 //******************************************************************
2 //
3 // Copyright 2017 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
22 /**
23  * @file
24  *
25  * This file provides C++ APIs for Notification Service for Accepted Providers.
26  */
27
28 #ifndef _NS_ACCEPTED_PROVIDERS_H_
29 #define _NS_ACCEPTED_PROVIDERS_H_
30
31 #include <map>
32 #include <mutex>
33 #include <algorithm>
34 #include "NSProvider.h"
35
36
37 namespace OIC
38 {
39     namespace Service
40     {
41         /**
42               * @class   NSAcceptedProviders
43               * @brief   This class provides a set of C++APIs for managing accepted Providers.
44               */
45         class NSAcceptedProviders
46         {
47             public :
48                 /**
49                       * Constructor of NSAcceptedProviders.
50                       *
51                       */
52                 NSAcceptedProviders()
53                 {
54                     removeProviders();
55                 }
56
57                 /**
58                       * Destructor of NSAcceptedProviders.
59                       */
60                 ~NSAcceptedProviders()
61                 {
62                     removeProviders();
63                 }
64
65                 /**
66                      *  request to get NSProvider pointer
67                      * @param id -id as string
68                      *
69                      * @return shared pointer to NSProvider
70                      */
71                 std::shared_ptr<NSProvider> getProvider(const std::string &id);
72
73                 /**
74                       *  request to add NSProvider pointer
75                       * @param shared pointer to NSProvider
76                       *
77                       */
78                 void addProvider(std::shared_ptr<NSProvider> provider);
79
80                 /**
81                       *  request to remove NSProvider
82                       * @param id -id as string
83                       *
84                       */
85                 void removeProvider(const std::string &id);
86
87                 /**
88                       *  request to check if NSProvider is accepted
89                       * @param id -id as string
90                       *
91                       * @return true if accepted else false
92                       */
93                 bool isAccepted(const std::string &id);
94
95                 /**
96                       *  get size of providers accepted.
97                       * @return m_providers size
98                       */
99                 int size();
100
101                 /**
102                       *  request to remove all NSProviders
103                       */
104                 void removeProviders();
105
106                 /**
107                       *  get the map of providers accepted.
108                       * @return m_providers  -map of accepted providers
109                       */
110                 std::map<std::string, std::shared_ptr<NSProvider> > getProviders();
111
112             private :
113                 std::map<std::string, std::shared_ptr<NSProvider> > m_providers;
114                 std::mutex m_mutex;
115         };
116     }
117 }
118
119 #endif //_NS_ACCEPTED_PROVIDERS_H_