3 * \file GraphicsCacheItem.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
8 * \author Angus Leeming
10 * Full author contact details are available in file CREDITS
12 * The graphics cache is a container of grfx::CacheItems.
13 * Each grfx::CacheItem, defined here represents a separate image file.
15 * The routines here can be used to load the graphics file into memory at
16 * which point (status() == grfx::Loaded).
17 * The user is then free to access image() in order to copy it and to then
18 * transform the copy (rotate, scale, clip) and to generate the pixmap.
20 * The graphics cache supports fully asynchronous:
21 * file conversion to a loadable format;
24 * Whether you get that, of course, depends on grfx::Converter and on the
25 * grfx::Image-derived image class.
28 #ifndef GRAPHICSCACHEITEM_H
29 #define GRAPHICSCACHEITEM_H
31 #include "GraphicsTypes.h"
34 #include <boost/utility.hpp>
35 #include <boost/scoped_ptr.hpp>
36 #include <boost/signals/signal0.hpp>
45 /// A grfx::Cache item holder.
46 class CacheItem : boost::noncopyable {
49 CacheItem(string const & file);
51 /// Define an empty d-tor out-of-line to keep boost::scoped_ptr happy.
55 string const & filename() const;
57 /// It's in the cache. Now start the loading process.
58 void startLoading() const;
60 /** Monitor any changes to the file.
61 * There is no point monitoring the file before startLoading() is
64 void startMonitoring() const;
66 bool monitoring() const;
67 /** Returns the check sum of filename() so that, for example, you can
68 * ascertain whether to output a new PostScript version of the file
71 unsigned long checksum() const;
73 /** Get the image associated with filename().
74 * If the image is not yet loaded, returns 0.
75 * This routine returns a pointer to const; if you want to modify it,
76 * create a copy and modify that.
78 Image const * image() const;
80 /// How far have we got in loading the image?
81 ImageStatus status() const;
83 /** Connect and you'll be informed when the loading status of the image
86 typedef boost::signal0<void>::slot_type slot_type;
88 boost::signals::connection connect(slot_type const &) const;
91 /// Use the Pimpl idiom to hide the internals.
94 /// The pointer never changes although *pimpl_'s contents may.
95 boost::scoped_ptr<Impl> const pimpl_;
100 #endif // GRAPHICSCACHEITEM_H