]> git.lyx.org Git - lyx.git/blob - src/graphics/Previews.h
namespace grfx -> lyx::graphics
[lyx.git] / src / graphics / Previews.h
1 // -*- C++ -*-
2 /**
3  *  \file Previews.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Angus Leeming
8  *
9  * Full author contact details are available in file CREDITS
10  *
11  *  grfx::Previews is a singleton class that stores the grfx::PreviewLoader
12  *  for each buffer requiring one.
13  */
14
15 #ifndef PREVIEWS_H
16 #define PREVIEWS_H
17
18 #include "LString.h"
19 #include <boost/utility.hpp>
20 #include <boost/scoped_ptr.hpp>
21
22 class Buffer;
23
24 namespace lyx {
25 namespace graphics {
26
27 class PreviewLoader;
28
29 class Previews : boost::noncopyable {
30 public:
31         /// a wrapper for lyxrc.preview
32         static bool activated();
33
34         /// This is a singleton class. Get the instance.
35         static Previews & get();
36
37         /** Returns the PreviewLoader for this buffer.
38          *  Used by individual insets to update their own preview.
39          *  We assert that (buffer != 0) but do not pass a Buffer &
40          *  so that insets do not need to #include buffer.h
41          */
42         PreviewLoader & loader(Buffer const * buffer) const;
43
44         /** Called from the Buffer d-tor.
45          *  If (buffer == 0), does nothing.
46          */
47         void removeLoader(Buffer const * buffer) const;
48
49         /** For a particular buffer, initiate the generation of previews
50          *  for each and every snippetof LaTeX that's of interest with
51          *  a single forked process.
52          *  If (buffer == 0), does nothing.
53          */
54         void generateBufferPreviews(Buffer const & buffer) const;
55
56 private:
57         /** Make the c-tor, d-tor private so we can control how many objects
58          *  are instantiated.
59          */
60         Previews();
61         ///
62         ~Previews();
63
64         /// Use the Pimpl idiom to hide the internals.
65         class Impl;
66         /// The pointer never changes although *pimpl_'s contents may.
67         boost::scoped_ptr<Impl> const pimpl_;
68 };
69
70 } // namespace graphics
71 } // namespace lyx
72
73 #endif // PREVIEWS_H