3 * \file GraphicsCacheItem.h
4 * Copyright 2002 the LyX Team
5 * Read the file COPYING
7 * \author Baruch Even <baruch.even@writeme.com>
8 * \author Angus Leeming <leeming@lyx.org>
10 * The graphics cache is a container of grfx::CacheItems.
11 * Each grfx::CacheItem, defined here represents a separate image file.
13 * The routines here can be used to load the graphics file into memory at
14 * which point (status() == grfx::Loaded).
15 * The user is then free to access image() in order to copy it and to then
16 * transform the copy (rotate, scale, clip) and to generate the pixmap.
18 * The graphics cache supports fully asynchronous:
19 * file conversion to a loadable format;
22 * Whether you get that, of course, depends on grfx::Converter and on the
23 * grfx::Image-derived image class.
26 #ifndef GRAPHICSCACHEITEM_H
27 #define GRAPHICSCACHEITEM_H
33 #include "GraphicsTypes.h"
36 #include <boost/utility.hpp>
37 #include <boost/scoped_ptr.hpp>
38 #include <boost/signals/signal0.hpp>
47 /// A grfx::Cache item holder.
48 class CacheItem : boost::noncopyable {
51 CacheItem(string const & file);
53 /// Define an empty d-tor out-of-line to keep boost::scoped_ptr happy.
57 string const & filename() const;
59 /// It's in the cache. Now start the loading process.
60 void startLoading() const;
62 /** Monitor any changes to the file.
63 * There is no point monitoring the file before startLoading() is
66 void startMonitoring() const;
68 bool monitoring() const;
69 /** Returns the check sum of filename() so that, for example, you can
70 * ascertain whether to output a new PostScript version of the file
73 unsigned long checksum() const;
75 /** Get the image associated with filename().
76 * If the image is not yet loaded, returns 0.
77 * This routine returns a pointer to const; if you want to modify it,
78 * create a copy and modify that.
80 Image const * image() const;
82 /// How far have we got in loading the image?
83 ImageStatus status() const;
85 /** Connect and you'll be informed when the loading status of the image
88 typedef boost::signal0<void>::slot_type slot_type;
90 boost::signals::connection connect(slot_type const &) const;
93 /// Use the Pimpl idiom to hide the internals.
96 /// The pointer never changes although *pimpl_'s contents may.
97 boost::scoped_ptr<Impl> const pimpl_;
102 #endif // GRAPHICSCACHEITEM_H