diff options
author | Mike Buland <eichlan@xagasoft.com> | 2009-08-20 22:25:50 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2009-08-20 22:25:50 +0000 |
commit | 539d6bf53bcece62e29d3d7d900b83dc03275b65 (patch) | |
tree | 913ca2fc435fd94ccbbb67b482b3f59a3cdbcb51 /src/cache.h | |
parent | f01674e99a467e9eb99323130a1e1add4c57eda2 (diff) | |
download | libbu++-539d6bf53bcece62e29d3d7d900b83dc03275b65.tar.gz libbu++-539d6bf53bcece62e29d3d7d900b83dc03275b65.tar.bz2 libbu++-539d6bf53bcece62e29d3d7d900b83dc03275b65.tar.xz libbu++-539d6bf53bcece62e29d3d7d900b83dc03275b65.zip |
Added a typedef to the cache, and most list manipulation functions now return
a reference to the list, so you can chain appends and whatnot.
Diffstat (limited to '')
-rw-r--r-- | src/cache.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/cache.h b/src/cache.h index 98775d2..53b4f7a 100644 --- a/src/cache.h +++ b/src/cache.h | |||
@@ -228,6 +228,13 @@ namespace Bu | |||
228 | return hEnt.has( cId ) || pStore->has( cId ); | 228 | return hEnt.has( cId ) || pStore->has( cId ); |
229 | } | 229 | } |
230 | 230 | ||
231 | /** | ||
232 | * Retrieve an object from the cache and return a pointer to it. | ||
233 | * The object returned may be loaded from backend storage if needed, | ||
234 | * or the currently live object will be returned. | ||
235 | *@param cId The id of the object to load. | ||
236 | *@returns A pointer to the object. | ||
237 | */ | ||
231 | Ptr get( const keytype &cId ) | 238 | Ptr get( const keytype &cId ) |
232 | { | 239 | { |
233 | TRACE( cId ); | 240 | TRACE( cId ); |
@@ -242,6 +249,16 @@ namespace Bu | |||
242 | } | 249 | } |
243 | } | 250 | } |
244 | 251 | ||
252 | /** | ||
253 | * Retrieve a handle to an object without loading it now. This function | ||
254 | * will return a pointer that has not yet been "realized" but can be | ||
255 | * used normally. Upon initial use in any way the object will be | ||
256 | * loaded from the cache, either linking against the already loaded | ||
257 | * object or loading it fresh from the backend storage. The advantage | ||
258 | * of this is that you recieve a usable handle to the data, but it | ||
259 | * does not count as a reference yet, meaning that the data is loaded | ||
260 | * when you need it, not before. | ||
261 | */ | ||
245 | Ptr getLazy( const keytype &cId ) | 262 | Ptr getLazy( const keytype &cId ) |
246 | { | 263 | { |
247 | TRACE( cId ); | 264 | TRACE( cId ); |
@@ -297,7 +314,8 @@ namespace Bu | |||
297 | hEnt.erase( cId ); | 314 | hEnt.erase( cId ); |
298 | } | 315 | } |
299 | 316 | ||
300 | Bu::List<keytype> getKeys() | 317 | typedef Bu::List<keytype> KeyList; |
318 | KeyList getKeys() | ||
301 | { | 319 | { |
302 | return pStore->getKeys(); | 320 | return pStore->getKeys(); |
303 | } | 321 | } |