Merge branch 'ct' of git.pipapo.org:cinelerra-ct into ct
[cinelerra_cv/ct.git] / cinelerra / cachebase.h
blob1e806a802a32b0d49c46e1d358c9249626287030
1 #ifndef CACHEBASE_H
2 #define CACHEBASE_H
5 #include "asset.inc"
6 #include "linklist.h"
7 #include "mutex.inc"
8 #include <stdint.h>
11 // Store rendered elements from files but not the files.
12 // Drawing caches must be separate from file caches to avoid
13 // delaying other file accesses for the drawing routines.
16 class CacheItemBase : public ListItem<CacheItemBase>
18 public:
19 CacheItemBase();
20 virtual ~CacheItemBase();
24 virtual int get_size();
26 // asset_id - supplied by user if the cache is not part of a file.
27 // Used for fast accesses.
28 int asset_id;
29 // path is needed since the item may need to be deleted based on file.
30 // Used for deletion.
31 char *path;
32 // Number of last get or put operation involving this object.
33 int age;
34 // Starting point of item in asset's native rate.
35 int64_t position;
40 class CacheBase : public List<CacheItemBase>
42 public:
43 CacheBase();
44 virtual ~CacheBase();
46 int get_age();
48 void remove_all();
50 // Remove all items with the asset id.
51 void remove_asset(Asset_GC asset);
53 // Insert item in list in ascending position order.
54 void put_item(CacheItemBase *item);
56 // Get first item from list with matching position or 0 if none found.
57 CacheItemBase* get_item(int64_t position);
59 // Called when done with the item returned by get_.
60 // Ignore if item was 0.
61 void unlock();
63 // Get ID of oldest member.
64 // Called by MWindow::age_caches.
65 int get_oldest();
67 // Delete oldest item. Return 0 if successful. Return 1 if nothing to delete.
68 int delete_oldest();
70 // Calculate current size of cache in bytes
71 int64_t get_memory_usage();
73 Mutex *lock;
74 // Current position of search
75 CacheItemBase *current_item;
80 #endif
82 // Local Variables:
83 // mode: C++
84 // c-file-style: "linux"
85 // End: