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