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 RCM_DATACACHE_H_
22 #define RCM_DATACACHE_H_
28 #include "CacheTypes.h"
29 #include "ExpiryTimer.h"
38 typedef unsigned int TimerID;
39 typedef std::function<void(TimerID)> TimerCB;
45 void initializeDataCache(PrimitiveResourcePtr pResource);
47 CacheID addSubscriber(CacheCB func, REPORT_FREQUENCY rf, long repeatTime);
48 CacheID deleteSubscriber(CacheID id);
50 CACHE_STATE getCacheState() const;
51 const RCSResourceAttributes getCachedData() const;
52 const PrimitiveResourcePtr getPrimitiveResource() const;
55 bool isEmptySubscriber() const;
59 PrimitiveResourcePtr sResource;
62 RCSResourceAttributes attributes;
67 std::unique_ptr<SubscriberInfo> subscriberList;
69 ExpiryTimer networkTimer;
70 ExpiryTimer pollingTimer;
71 TimerID networkTimeOutHandle;
72 TimerID pollingHandle;
79 // for requestCB from base
80 void onObserve(const HeaderOptions &_hos,
81 const ResponseStatement &_rep, int _result, int _seq);
82 void onGet(const HeaderOptions &_hos, const ResponseStatement &_rep, int _result);
83 void onTimeOut(const unsigned int timerID);
84 void onPollingOut(const unsigned int timerID);
86 CacheID generateCacheID();
87 SubscriberInfoPair findSubscriber(CacheID id);
88 void notifyObservers(RCSResourceAttributes Att);
90 } // namespace Service
93 #endif /* RCM_DATACACHE_H_ */