Add ResourceCache Sconscript
[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     static ResourceCacheManager * getInstance();
37
38     CacheID requestResourceCache(
39             PrimitiveResourcePtr pResource,
40                 CacheCB func = NULL, REPORT_FREQUENCY rf = REPORT_FREQUENCY::NONE, long time = 0l);
41
42     OCStackResult cancelResourceCache(PrimitiveResourcePtr pResource, CacheID id);
43
44     OCStackResult updateResourceCache(PrimitiveResourcePtr pResource);
45
46     CachedDataPtr getCachedData(PrimitiveResourcePtr pResource);
47     CachedDataPtr getCachedData(CacheID id);
48
49     CACHE_STATE getResourceCacheState(PrimitiveResourcePtr pResource);
50     CACHE_STATE getResourceCacheState(CacheID id);
51
52     ~ResourceCacheManager();
53 private:
54     ResourceCacheManager();
55
56     static ResourceCacheManager * s_instance;
57     static std::mutex s_mutexForCreation;
58     static std::unique_ptr<std::list<DataCachePtr>> s_cacheDataList;
59
60     DataCachePtr findDataCache(PrimitiveResourcePtr pResource);
61     DataCachePtr findDataCache(CacheID id);
62 };
63
64 #endif /* RESOURCECACHEMANAGER_H_ */