4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 // Store rendered elements from files but not the files.
32 // Drawing caches must be separate from file caches to avoid
33 // delaying other file accesses for the drawing routines.
36 class CacheItemBase : public ListItem<CacheItemBase>
40 virtual ~CacheItemBase();
42 virtual int get_size();
44 // source_id - supplied by user if the cache is not part of a file.
45 // Used for fast accesses.
47 // path is needed since the item may need to be deleted based on file.
50 // Number of last get or put operation involving this object.
52 // Starting point of item in asset's native rate.
58 class CacheBase : public List<CacheItemBase>
64 void age_cache(int64_t max_items);
66 int cache_items() { return total_items; }
69 // Insert item in list in ascending position order.
70 void put_item(CacheItemBase *item);
71 // Get first item from list with matching position or 0 if none found.
72 CacheItemBase* get_item(int64_t position);
74 void del_item(CacheItemBase *item);
75 int delete_item(CacheItemBase *item);
76 // Remove all items with the asset id.
77 void remove_asset(Asset *asset);
78 // Called when done with the item returned by get_.
79 // Ignore if item was 0.
81 // Delete oldest item.
82 // Return number of bytes freed if successful. Return 0 if nothing to delete.
84 // Calculate current size of cache in bytes
85 int64_t get_memory_usage();
89 // Current position of search
90 CacheItemBase *current_item;