]> git.lyx.org Git - lyx.git/blob - src/graphics/GraphicsCache.h
one small private fix in mathed, put noncopyable and tie into boost namespace
[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 #include <boost/utility.hpp>
24 #include <boost/smart_ptr.hpp>
25
26 class GraphicsCacheItem;
27
28 /** GraphicsCache is the manager of the image cache.
29     It is responsible of create the GraphicsCacheItem's and maintain them.
30     
31     GraphicsCache is a singleton class, there should be only one instance of
32     it at any moment.
33 */
34 class GraphicsCache : public boost::noncopyable {
35 public:
36         /// Get the instance of the class.
37         static GraphicsCache & getInstance();
38         /// Public destructor due to compiler warnings.
39         ~GraphicsCache();
40
41         typedef boost::shared_ptr<GraphicsCacheItem> shared_ptr_item;
42
43         /// Add a file to the cache.
44         shared_ptr_item addFile(string const & filename);
45
46 private:
47         /// Remove a cache item if it's count has gone to zero.
48         void removeFile(string const & filename);
49         
50         /// Private c-tor so we can control how many objects are instantiated.
51         GraphicsCache() {}
52         
53         ///
54         typedef std::map<string, shared_ptr_item> CacheType;
55         ///
56         CacheType cache;
57         
58         /** We need this so that an Item can tell the cache that it should be
59             deleted. (to call removeFile).
60             It also helps removing a warning gcc emits. */
61         friend class GraphicsCacheItem;
62 };
63 #endif