bc36d7fa61070834c54bca7ea936b56cc7afe49d
[platform/upstream/iotivity.git] / service / basis / resourceCache / include / ResourceCacheManager.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 RESOURCECACHEMANAGER_H_
22 #define RESOURCECACHEMANAGER_H_
23
24 #include <list>
25 #include <string>
26
27 #include "OCPlatform.h"
28 #include "CacheTypes.h"
29 #include "DataCache.h"
30
31 #define CACHE_TAG PCF("CACHE")
32
33 class ResourceCacheManager
34 {
35 public:
36     ResourceCacheManager * getInstance();
37
38     CacheID requestResourceCache(
39             PrimitiveResource & pResource,
40                 CacheCB func = NULL, REPORT_FREQUENCY rf = REPORT_FREQUENCY::NONE, long time = 0l);
41
42 //    OCStackResult cancelResourceCache(std::string address, std::string uri);
43     OCStackResult cancelResourceCache(PrimitiveResource & pResource, CacheID id);
44
45 //    OCStackResult updateResourceCache(std::string address, std::string uri);
46     OCStackResult updateResourceCache(PrimitiveResource & pResource);
47
48 //    OCStackResult getResourceCache(std::string address, std::string uri);
49     OCStackResult getResourceCache(PrimitiveResource & pResource);
50
51 private:
52     ResourceCacheManager();
53     ~ResourceCacheManager();
54
55     static ResourceCacheManager * s_instance;
56     static std::mutex s_mutexForCreation;
57     static std::list< DataCache * > * s_cacheDataList;
58
59     DataCache * findCacheHandler(PrimitiveResource & pResource);
60 };
61
62 #endif /* RESOURCECACHEMANAGER_H_ */