]> git.lyx.org Git - lyx.git/blob - src/graphics/GraphicsCacheItem.h
remove noload/don't typeset
[lyx.git] / src / graphics / GraphicsCacheItem.h
1 // -*- C++ -*-
2 /**
3  * \file GraphicsCacheItem.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Baruch Even 
8  * \author Angus Leeming 
9  *
10  * Full author contact details are available in file CREDITS
11  *
12  * The graphics cache is a container of grfx::CacheItems.
13  * Each grfx::CacheItem, defined here represents a separate image file.
14  *
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.
19  *
20  * The graphics cache supports fully asynchronous:
21  * file conversion to a loadable format;
22  * file loading.
23  *
24  * Whether you get that, of course, depends on grfx::Converter and on the
25  * grfx::Image-derived image class.
26  */
27
28 #ifndef GRAPHICSCACHEITEM_H
29 #define GRAPHICSCACHEITEM_H
30
31 #ifdef __GNUG__
32 #pragma interface
33 #endif
34
35 #include "GraphicsTypes.h"
36 #include "LString.h"
37
38 #include <boost/utility.hpp>
39 #include <boost/scoped_ptr.hpp>
40 #include <boost/signals/signal0.hpp>
41
42 class InsetGraphics;
43
44 namespace grfx {
45
46 class Image;
47 class Converter;
48
49 /// A grfx::Cache item holder.
50 class CacheItem : boost::noncopyable {
51 public:
52         ///
53         CacheItem(string const & file);
54
55         /// Define an empty d-tor out-of-line to keep boost::scoped_ptr happy.
56         ~CacheItem();
57
58         ///
59         string const & filename() const;
60
61         /// It's in the cache. Now start the loading process.
62         void startLoading() const;
63
64         /** Monitor any changes to the file.
65          *  There is no point monitoring the file before startLoading() is
66          *  invoked.
67          */
68         void startMonitoring() const;
69         ///
70         bool monitoring() const;
71         /** Returns the check sum of filename() so that, for example, you can
72          *  ascertain whether to output a new PostScript version of the file
73          *  for a LaTeX run.
74          */
75         unsigned long checksum() const;
76
77         /** Get the image associated with filename().
78          *  If the image is not yet loaded, returns 0.
79          *  This routine returns a pointer to const; if you want to modify it,
80          *  create a copy and modify that.
81          */
82         Image const * image() const;
83
84         /// How far have we got in loading the image?
85         ImageStatus status() const;
86
87         /** Connect and you'll be informed when the loading status of the image
88          *  changes.
89          */
90         typedef boost::signal0<void>::slot_type slot_type;
91         ///
92         boost::signals::connection connect(slot_type const &) const;
93
94 private:
95         /// Use the Pimpl idiom to hide the internals.
96         class Impl;
97
98         /// The pointer never changes although *pimpl_'s contents may.
99         boost::scoped_ptr<Impl> const pimpl_;
100 };
101
102 } // namespace grfx
103
104 #endif // GRAPHICSCACHEITEM_H