1 //******************************************************************
3 // Copyright 2014 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
11 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #ifndef RESOURCEMANAGER_H_
22 #define RESOURCEMANAGER_H_
24 #include "NotificationManager.h"
27 using namespace OCPlatform;
30 class OICPlatformConfig;
31 class VirtualRepresentation;
40 static ResourceManager *s_instance;
41 static mutex s_mutexForCreation;
42 static std::list< VirtualRepresentation > s_resourceList;
43 static std::string s_extraStr;
45 void foundResourceforhosting(std::shared_ptr< OCResource > resource);
47 void checkResourceDBPolicy();
48 void saveResourceDB();
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;
56 static ResourceManager *getInstance();
58 void findNMResource(bool isHosting);
60 void onFoundforHostingDefault(std::shared_ptr< OCResource > resource);
61 void onObserveDefault(AttributeMap &inputAttMap, OCResourceHandle resourceHandle);
62 void notifyObserversDefault(OCResourceHandle resourceHandle);
64 void startHosting(std::shared_ptr< OCResource > resource);
65 void notifyObservers(OCResourceHandle resourceHandle);
67 VirtualRepresentation findVirtualRepresentation(std::string uri);
68 AttributeMap copyAttributeMap(AttributeMap &inputAttMap);
69 bool isEmptyAttributeMap(AttributeMap &inputAttMap);
70 void printAttributeMap(AttributeMap &inputAttMap);
72 void addExtraStr(std::string str);
73 std::string getExtraStr();
76 #endif /* RESOURCEMANAGER_H_ */