2 /* This file is part of
3 * =================================================
5 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich.
7 * Copyright 1995-2001 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 : boost::noncopyable {
36 /// Get the instance of the class.
37 static GraphicsCache & getInstance();
38 /// Public destructor due to compiler warnings.
41 typedef boost::shared_ptr<GraphicsCacheItem> shared_ptr_item;
43 /// Add a file to the cache.
44 shared_ptr_item addFile(string const & filename);
47 /// Remove a cache item if it's count has gone to zero.
48 void removeFile(string const & filename);
50 /// Private c-tor so we can control how many objects are instantiated.
54 typedef std::map<string, shared_ptr_item> CacheType;
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;