3 * \file GraphicsCache.h
4 * Copyright 2002 the LyX Team
5 * Read the file COPYING
7 * \author Baruch Even <baruch.even@writeme.com>
8 * \author Angus Leeming <a.leeming@ic.ac.uk>
10 * grfx::GCache is the manager of the image cache.
11 * It is responsible for creating the grfx::GCacheItem's and maintaining them.
13 * grfx::GCache is a singleton class. It is possible to have only one
14 * instance of it at any moment.
17 #ifndef GRAPHICSCACHE_H
18 #define GRAPHICSCACHE_H
24 #include "GraphicsTypes.h"
27 #include <boost/utility.hpp>
35 class GCache : boost::noncopyable {
38 /// This is a singleton class. Get the instance.
39 static GCache & get();
44 /// Add a file to the cache (or modify an existing image).
45 void update(InsetGraphics const &);
47 /** Remove the data associated with this inset.
48 * Called from the InsetGraphics d-tor.
50 void remove(InsetGraphics const &);
52 /** No processing of the image will take place until this call is
55 void startLoading(InsetGraphics const &);
57 /** If (changed_background == true), then the background color of the
58 * graphics inset has changed. Update all images.
59 * Else, the preferred display type has changed.
60 * Update the view of all insets whose display type is DEFAULT.
62 void changeDisplay(bool changed_background = false);
64 /// Get the image referenced by a particular inset.
65 ImagePtr const image(InsetGraphics const &) const;
67 /// How far have we got in loading the image?
68 ImageStatus status(InsetGraphics const &) const;
71 /** Make the c-tor private so we can control how many objects
76 /// The cache contains data of this type.
77 typedef boost::shared_ptr<GCacheItem> CacheItemType;
79 /** The cache contains one item per file, so use a map to find the
80 * cache item quickly by filename.
81 * Note that each cache item can have multiple views, potentially one
82 * per inset that references the original file.
84 typedef std::map<string, CacheItemType> CacheType;
86 /// Search the cache by inset.
87 CacheType::const_iterator find(InsetGraphics const &) const;
89 CacheType::iterator find(InsetGraphics const &);
91 /** Store a pointer to the cache so that we can forward declare
100 #endif // GRAPHICSCACHE_H