1 #include <lib/dvb/servicecache.h>
2 #include <lib/system/econfig.h>
4 void eServiceCacheBase::enterDirectory(const eServiceReference
&parent
, Signal1
<void, const eServiceReference
&> &callback
)
6 // int pLockActive = eConfig::getInstance()->pLockActive();
7 std::map
<eServiceReference
,eNode
>::iterator i
=cache
.find(parent
);
11 node
=&cache
.insert(std::pair
<eServiceReference
,eNode
>(parent
, eNode())).first
->second
;
12 loadNode(*node
, parent
);
16 for (std::list
<eServiceReference
>::iterator
i(node
->content
.begin()); i
!= node
->content
.end(); ++i
)
20 void eServiceCacheBase::leaveDirectory(const eServiceReference
&parent
)
22 std::map
<eServiceReference
,eNode
>::iterator i
=cache
.find(parent
);
24 eDebug("leaveDirectory on non-cached directory!");
27 eNode
&node
=i
->second
;
28 if (node
.removeRef() <= 0)
33 void eServiceCacheBase::addPersistentService(const eServiceReference
&serviceref
, eService
*service
)
38 services
.insert(std::pair
<eServiceReference
, eCachedService
>(serviceref
, c
));
41 eService
*eServiceCacheBase::addRef(const eServiceReference
&serviceref
)
43 if (services
.find(serviceref
) == services
.end()) // service not exist in cache ?
45 eCachedService c
; // create new Cache Entry
46 c
.refcnt
=1; // currently one Object holds a reference to the new cache entry
47 c
.service
=createService(serviceref
);
50 eDebug("createService failed!");
53 services
.insert(std::pair
<eServiceReference
,eCachedService
>(serviceref
, c
));
57 eCachedService
&c
=services
.find(serviceref
)->second
;
64 void eServiceCacheBase::removeRef(const eServiceReference
&serviceref
)
66 std::map
<eServiceReference
,eCachedService
>::iterator c
=services
.find(serviceref
);
67 if (c
== services
.end())
69 eDebug("removeRef on non-existing service!");
72 if ((c
->second
.refcnt
!= -1) && ! --c
->second
.refcnt
)
74 delete c
->second
.service
;