343881b3b9a7816663b2f2ced5121632a0e5c9f0
[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 <map>
25 #include <memory>
26 #include <string>
27 #include "OCPlatform.h"
28 #include "OCResource.h"
29 #include "OCResourceResponse.h"
30 #include "ocstack.h"
31
32 #include "NotificationManager.h"
33
34 using namespace OC;
35 using namespace OCPlatform;
36
37 class VirtualRepresentation;
38
39 class ResourceManager
40 {
41
42 private:
43     static ResourceManager *s_instance;
44
45     static std::list< VirtualRepresentation > s_resourceList;
46
47     static std::string s_extraStr;
48
49     void foundResourceforhosting(std::shared_ptr< OCResource > resource);
50
51     void checkResourceDBPolicy();
52     void saveResourceDB();
53
54 public:
55     ResourceManager();
56     virtual ~ResourceManager();
57
58     static ResourceManager *getInstance();
59     VirtualRepresentation findVirtualRepresentation(std::string uri);
60
61     OCStackResult findNMResource(const std::string& host , const std::string& resourceName ,
62             bool ishosting);
63     void startHosting(std::shared_ptr< OCResource > resource);
64
65     AttributeMap copyAttributeMap(AttributeMap &inputAttMap);
66     bool isEmptyAttributeMap(AttributeMap &inputAttMap);
67
68     void printAttributeMap(AttributeMap &inputAttMap);
69     void onFoundReport(std::shared_ptr< OCResource > resource);
70
71     void addExtraStr(std::string str);
72     std::string getExtraStr();
73 };
74
75 #endif /* RESOURCEMANAGER_H_ */