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