iotivity 0.9.0
[platform/upstream/iotivity.git] / service / notification-manager / NotificationManager / include / ResourceManager.h
1 //******************************************************************
2 //
3 // Copyright 2014 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 RESOURCEMANAGER_H_
22 #define RESOURCEMANAGER_H_
23
24 #include "NotificationManager.h"
25
26 using namespace OC;
27 using namespace OCPlatform;
28
29
30 class OICPlatformConfig;
31 class VirtualRepresentation;
32
33 class ResourceManager
34 {
35
36 private:
37     ResourceManager();
38     ~ResourceManager();
39
40     static ResourceManager *s_instance;
41     static mutex s_mutexForCreation;
42     static std::list< VirtualRepresentation > s_resourceList;
43     static std::string s_extraStr;
44
45     void foundResourceforhosting(std::shared_ptr< OCResource > resource);
46
47     void checkResourceDBPolicy();
48     void saveResourceDB();
49
50 public:
51
52         std::function< void(std::shared_ptr< OCResource > resource) > m_onFoundforHosting;
53         std::function< void(AttributeMap &inputAttMap, OCResourceHandle resourceHandle) > m_onObserve;
54         std::function< void(OCResourceHandle resourceHandle) > m_notify;
55
56     static ResourceManager *getInstance();
57
58     void findNMResource(bool isHosting);
59
60     void onFoundforHostingDefault(std::shared_ptr< OCResource > resource);
61     void onObserveDefault(AttributeMap &inputAttMap, OCResourceHandle resourceHandle);
62     void notifyObserversDefault(OCResourceHandle resourceHandle);
63
64     void startHosting(std::shared_ptr< OCResource > resource);
65     void notifyObservers(OCResourceHandle resourceHandle);
66
67     VirtualRepresentation findVirtualRepresentation(std::string uri);
68     AttributeMap copyAttributeMap(AttributeMap &inputAttMap);
69     bool isEmptyAttributeMap(AttributeMap &inputAttMap);
70     void printAttributeMap(AttributeMap &inputAttMap);
71
72     void addExtraStr(std::string str);
73     std::string getExtraStr();
74 };
75
76 #endif /* RESOURCEMANAGER_H_ */