]> git.lyx.org Git - lyx.git/blob - src/graphics/GraphicsCache.h
d64df5f5d321193930dcc2b9c1fb2ab5433721d7
[lyx.git] / src / graphics / GraphicsCache.h
1 // -*- C++ -*-
2 /* This file is part of
3  * =================================================
4  * 
5  *          LyX, The Document Processor
6  *          Copyright 1995 Matthias Ettrich.
7  *          Copyright 1995-2000 The LyX Team.
8  *
9  *          This file Copyright 2000 Baruch Even
10  * ================================================= */
11
12 #ifndef GRAPHICSCACHE_H
13 #define GRAPHICSCACHE_H
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include <map>
20
21 #include "LString.h"
22 #include "GraphicsCacheItem.h"
23
24 /** GraphicsCache is the manager of the image cache, it is responsible to
25  * create the GraphicsCacheItem's and maintain them.
26  *
27  * GraphicsCache is a singleton class, there should be only one instance of
28  * it at any moment.
29  */
30 class GraphicsCache {
31 public:
32     /// Get the instance of the class.
33     static GraphicsCache * getInstance();
34
35     /// Add a file to the cache.
36     GraphicsCacheItem * addFile(string const & filename);
37
38 private:
39     /// Remove a cache item if it's count has gone to zero.
40     void removeFile(string const & filename);
41     
42     /// Private c-tor so we can control how many objects are instantiated.
43     GraphicsCache() {}
44
45     /// Private d-tor so that no-one will destroy us.
46     ~GraphicsCache();
47
48     /// Holder of the single instance of the class.
49     static GraphicsCache * singleton;
50
51     typedef std::map<string, GraphicsCacheItem *> CacheType;
52     CacheType cache;
53 };
54 #endif