1 //******************************************************************
3 // Copyright 2015 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 RESOURCECACHEMANAGER_H_
22 #define RESOURCECACHEMANAGER_H_
28 #include "OCPlatform.h"
29 #include "CacheTypes.h"
30 #include "DataCache.h"
32 #define CACHE_TAG PCF("CACHE")
34 class ResourceCacheManager
37 static ResourceCacheManager * getInstance();
39 CacheID requestResourceCache(
40 PrimitiveResourcePtr pResource,
41 CacheCB func = NULL, REPORT_FREQUENCY rf = REPORT_FREQUENCY::NONE, long time = 0l);
42 OCStackResult cancelResourceCache(PrimitiveResourcePtr pResource, CacheID id);
43 OCStackResult updateResourceCache(PrimitiveResourcePtr pResource);
45 const ResourceAttributes getCachedData(PrimitiveResourcePtr pResource) const;
46 const ResourceAttributes getCachedData(CacheID id) const;
48 CACHE_STATE getResourceCacheState(PrimitiveResourcePtr pResource) const;
49 CACHE_STATE getResourceCacheState(CacheID id) const;
51 ~ResourceCacheManager();
53 ResourceCacheManager();
55 static ResourceCacheManager * s_instance;
56 static std::mutex s_mutexForCreation;
57 static std::unique_ptr<std::list<DataCachePtr>> s_cacheDataList;
59 DataCachePtr findDataCache(PrimitiveResourcePtr pResource) const;
60 DataCachePtr findDataCache(CacheID id) const;
63 #endif /* RESOURCECACHEMANAGER_H_ */