]> git.lyx.org Git - lyx.git/blob - src/graphics/GraphicsConverter.h
rename/merge LyXLength related stuff
[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/scoped_ptr.hpp>
21 #include <boost/signal.hpp>
22 #include <boost/utility.hpp>
23
24 namespace lyx {
25
26 namespace support { class FileName; }
27
28 namespace graphics {
29
30 class Converter : boost::noncopyable {
31 public:
32         /// Can the conversion be performed?
33         static bool isReachable(std::string const & from_format_name,
34                                 std::string const & to_format_name);
35
36         /** One Converter per conversion ensures that the (hidden) signal
37          *  is always connected to the expected slot.
38          */
39         Converter(support::FileName const & from_file, std::string const & to_file_base,
40                   std::string const & from_format, std::string const & to_format);
41
42         /// Define an empty d-tor out-of-line to keep boost::scoped_ptr happy.
43         ~Converter();
44
45         /// We are explicit about when we begin the conversion process.
46         void startConversion() const;
47
48         /** Connect and you'll be informed when the conversion process has
49          *  finished.
50          *  If the conversion is succesful, then the listener is passed \c true.
51          */
52         typedef boost::signal<void(bool)> sig_type;
53         typedef sig_type::slot_type slot_type;
54         ///
55         boost::signals::connection connect(slot_type const &) const;
56
57         /** If the conversion is succesful, this returns the name of the
58          *  resulting file.
59          *  If conversion fails or has not been completed, however, it
60          *  returns an empty string.
61          */
62         support::FileName const & convertedFile() const;
63
64 private:
65         /// Use the Pimpl idiom to hide the internals.
66         class Impl;
67
68         /// The pointer never changes although *pimpl_'s contents may.
69         boost::scoped_ptr<Impl> const pimpl_;
70 };
71
72 } // namespace graphics
73 } // namespace lyx
74
75 #endif // GRAPHICSCONVERTER_H