6af94f3cbfafebc1f4a7ff3d2bab44f8667e6dc4
[platform/upstream/iotivity.git] / service / basis / resourceBroker / include / ResourceBroker.h
1 //******************************************************************
2 //
3 // Copyright 2015 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 #ifndef RESOURCEBROKER_H_
22 #define RESOURCEBROKER_H_
23
24 #include <functional>
25 #include <list>
26 #include <string>
27 #include <algorithm>
28 #include <mutex>
29 #include <condition_variable>
30
31 #include "BrokerTypes.h"
32 #include "DevicePresence.h"
33
34 class ResourceBroker
35 {
36 public:
37     ResourceBroker * getInstance();
38
39     OCStackResult hostResource(PrimitiveResource & pResource, BrokerCB cb);
40
41     OCStackResult cancelHostResource(PrimitiveResource & pResource);
42
43     OCStackResult getResourceState(PrimitiveResource & pResource);
44
45 private:
46     ResourceBroker();
47     ~ResourceBroker();
48
49     static ResourceBroker * s_instance;
50     static std::mutex s_mutexForCreation;
51     static std::list< DevicePresence * >  s_presenceList;
52
53     ResourcePresence * findResourcePresence(PrimitiveResource& pResource, BrokerCB cb);
54     DevicePresence * findDevicePresence(PrimitiveResource& pResource, BrokerCB cb);
55 };
56
57 #endif /* RESOURCEBROKER_H_ */