Update Snapshot(2018-02-28)
[platform/upstream/iotivity.git] / service / resource-encapsulation / src / resourceCache / include / ResourceCacheManager.h
index c1a14a7..ae02cac 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "CacheTypes.h"
 #include "DataCache.h"
+#include "ObserveCache.h"
 
 namespace OIC
 {
@@ -36,35 +37,47 @@ namespace OIC
         class ResourceCacheManager
         {
             public:
-                class InvalidParameterException: public RCSException
+                class HasNoCachedDataException: public RCSException
                 {
                     public:
-                        InvalidParameterException(std::string &&what)
+                        HasNoCachedDataException(std::string &&what)
                             : RCSException { std::move(what) } {}
                 };
 
                 static ResourceCacheManager *getInstance();
 
+                // throw InvalidParameterException;
                 CacheID requestResourceCache(
                     PrimitiveResourcePtr pResource, CacheCB func = NULL,
+                    CACHE_METHOD cm = CACHE_METHOD::ITERATED_GET,
                     REPORT_FREQUENCY rf = REPORT_FREQUENCY::NONE, long time = 0l);
+
+                // throw InvalidParameterException;
                 void cancelResourceCache(CacheID id);
 
-                void updateResourceCache(PrimitiveResourcePtr pResource) const;
+                // throw InvalidParameterException;
                 void updateResourceCache(CacheID id) const;
 
-                const ResourceAttributes getCachedData(PrimitiveResourcePtr pResource) const;
-                const ResourceAttributes getCachedData(CacheID id) const;
+                // throw InvalidParameterException;
+                // throw HasNoCachedDataException;
+                const RCSResourceAttributes getCachedData(CacheID id) const;
 
-                CACHE_STATE getResourceCacheState(PrimitiveResourcePtr pResource) const;
+                // throw InvalidParameterException;
                 CACHE_STATE getResourceCacheState(CacheID id) const;
 
+                // throw InvalidParameterException;
+                bool isCachedData(CacheID id) const;
+
             private:
                 static ResourceCacheManager *s_instance;
+                static std::mutex s_mutex;
                 static std::mutex s_mutexForCreation;
                 static std::unique_ptr<std::list<DataCachePtr>> s_cacheDataList;
                 std::map<CacheID, DataCachePtr> cacheIDmap;
 
+                std::list<ObserveCache::Ptr> m_observeCacheList;
+                std::map<CacheID, ObserveCache::Ptr> observeCacheIDmap;
+
                 ResourceCacheManager() = default;
                 ~ResourceCacheManager();
                 ResourceCacheManager(const ResourceCacheManager &) = delete;