beta-0.89.2
[luatex.git] / source / libs / poppler / poppler-src / poppler / PopplerCache.h
blob74010a2fa6bf3c9bf17112d66e4c34db16bea98c
1 //========================================================================
2 //
3 // PopplerCache.h
4 //
5 // This file is licensed under the GPLv2 or later
6 //
7 // Copyright (C) 2009 Koji Otani <sho@bbr.jp>
8 // Copyright (C) 2009, 2010 Albert Astals Cid <aacid@kde.org>
9 // Copyright (C) 2010 Carlos Garcia Campos <carlosgc@gnome.org>
11 //========================================================================
13 #ifndef POPPLER_CACHE_H
14 #define POPPLER_CACHE_H
16 #include "Object.h"
18 class PopplerCacheItem
20 public:
21 virtual ~PopplerCacheItem();
24 class PopplerCacheKey
26 public:
27 virtual ~PopplerCacheKey();
28 virtual bool operator==(const PopplerCacheKey &key) const = 0;
31 class PopplerCache
33 public:
34 PopplerCache(int cacheSizeA);
35 ~PopplerCache();
37 /* The item returned is owned by the cache */
38 PopplerCacheItem *lookup(const PopplerCacheKey &key);
40 /* The key and item pointers ownership is taken by the cache */
41 void put(PopplerCacheKey *key, PopplerCacheItem *item);
43 /* The max size of the cache */
44 int size();
46 /* The number of items in the cache */
47 int numberOfItems();
49 /* The n-th item in the cache */
50 PopplerCacheItem *item(int index);
52 /* The n-th key in the cache */
53 PopplerCacheKey *key(int index);
55 private:
56 PopplerCache(const PopplerCache &cache); // not allowed
58 PopplerCacheKey **keys;
59 PopplerCacheItem **items;
60 int lastValidCacheIndex;
61 int cacheSize;
64 class PopplerObjectCache
66 public:
67 PopplerObjectCache (int cacheSizeA, XRef *xrefA);
68 ~PopplerObjectCache();
70 Object *put(const Ref &ref);
71 Object *lookup(const Ref &ref, Object *obj);
73 private:
74 XRef *xref;
75 PopplerCache *cache;
78 #endif