]> git.lyx.org Git - lyx.git/blob - src/graphics/GraphicsConverter.h
Adapt code to comment
[lyx.git] / src / graphics / GraphicsConverter.h
1 // -*- C++ -*-
2 /**
3  * \file GraphicsConverter.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  * The controller of a conversion process from file AA of format A to
12  * file BB of format B.
13  * Once finished, a signal is emitted to inform any listeners (connected
14  * through the connect() method).
15  */
16
17 #ifndef GRAPHICSCONVERTER_H
18 #define GRAPHICSCONVERTER_H
19
20 #include <boost/signals2.hpp>
21
22 namespace lyx {
23
24 namespace support { class FileName; }
25
26 namespace graphics {
27
28 class Converter {
29 public:
30         /// Can the conversion be performed?
31         static bool isReachable(std::string const & from_format_name,
32                                 std::string const & to_format_name);
33
34         /** One Converter per conversion ensures that the (hidden) signal
35          *  is always connected to the expected slot.
36          */
37         Converter(support::FileName const & from_file, std::string const & to_file_base,
38                   std::string const & from_format, std::string const & to_format);
39
40         /// Needed for the pimpl
41         ~Converter();
42
43         /// We are explicit about when we begin the conversion process.
44         void startConversion() const;
45
46         /** Connect and you'll be informed when the conversion process has
47          *  finished.
48          *  If the conversion is successful, then the listener is passed \c true.
49          */
50         typedef boost::signals2::signal<void(bool)> sig_type;
51         typedef sig_type::slot_type slot_type;
52         ///
53         boost::signals2::connection connect(slot_type const &) const;
54
55         /** If the conversion is successful, this returns the name of the
56          *  resulting file.
57          *  If conversion fails or has not been completed, however, it
58          *  returns an empty string.
59          */
60         support::FileName const & convertedFile() const;
61
62 private:
63         /// noncopyable
64         Converter(Converter const &);
65         void operator=(Converter const &);
66
67         /// Use the Pimpl idiom to hide the internals.
68         class Impl;
69         /// The pointer never changes although *pimpl_'s contents may.
70         Impl * const pimpl_;
71 };
72
73 } // namespace graphics
74 } // namespace lyx
75
76 #endif // GRAPHICSCONVERTER_H