2 /* This file is part of
3 * =================================================
5 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich.
7 * Copyright 1995-2000 The LyX Team.
9 * This file Copyright 2000 Baruch Even
10 * ================================================= */
12 #ifndef GRAPHICSCACHE_H
13 #define GRAPHICSCACHE_H
22 #include "GraphicsCacheItem.h"
23 #include <boost/utility.hpp>
24 #include <boost/smart_ptr.hpp>
26 class GraphicsCacheItem;
28 /** GraphicsCache is the manager of the image cache.
29 It is responsible of create the GraphicsCacheItem's and maintain them.
31 GraphicsCache is a singleton class, there should be only one instance of
34 class GraphicsCache : public noncopyable {
36 /// Get the instance of the class.
37 static GraphicsCache * getInstance();
39 typedef boost::shared_ptr<GraphicsCacheItem> shared_ptr_item;
41 /// Add a file to the cache.
42 shared_ptr_item addFile(string const & filename);
45 /// Remove a cache item if it's count has gone to zero.
46 void removeFile(string const & filename);
48 /// Private c-tor so we can control how many objects are instantiated.
51 /// Private d-tor so that no-one will destroy us.
54 /// Holder of the single instance of the class.
55 static GraphicsCache * singleton;
57 typedef std::map<string, shared_ptr_item> CacheType;
61 /** We need this so that an Item can tell the cache that it should be
62 deleted. (to call removeFile).
63 It also helps removing a warning gcc emits. */
64 friend class GraphicsCacheItem;