]> git.lyx.org Git - lyx.git/blob - src/graphics/GraphicsConverter.h
8bd994f5c9d770ec2e974abac4fbeeafc23e3820
[lyx.git] / src / graphics / GraphicsConverter.h
1 // -*- C++ -*-
2 /**
3  *  \file GraphicsConverter.h
4  *  Read the file COPYING
5  *
6  *  \author Angus Leeming 
7  *
8  * Full author contact details available in file CREDITS
9  *
10  *  The controller of a conversion process from file AA of format A to
11  *  file BB of format B.
12  *  Once finished, a signal is emitted to inform any listeners (connected
13  *  through the connect() method).
14  */
15
16 #ifndef GRAPHICSCONVERTER_H
17 #define GRAPHICSCONVERTER_H
18
19 #ifdef __GNUG__
20 #pragma interface
21 #endif
22
23 #include "LString.h"
24 #include <boost/signals/signal1.hpp>
25 #include <boost/scoped_ptr.hpp>
26 #include <boost/utility.hpp>
27
28 namespace grfx {
29
30 class Converter : boost::noncopyable {
31 public:
32         /// Can the conversion be performed?
33         static bool isReachable(string const & from_format_name,
34                                 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(string const & from_file,   string const & to_file_base,
40                   string const & from_format, 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::signal1<void, bool>::slot_type slot_type;
53         ///
54         boost::signals::connection connect(slot_type const &) const;
55
56         /** If the conversion is succesful, this returns the name of the
57          *  resulting file.
58          *  If conversion fails or has not been completed, however, it
59          *  returns an empty string.
60          */
61         string const & convertedFile() const;
62
63 private:
64         /// Use the Pimpl idiom to hide the internals.
65         class Impl;
66
67         /// The pointer never changes although *pimpl_'s contents may.
68         boost::scoped_ptr<Impl> const pimpl_;
69 };
70
71 } // namespace grfx
72
73 #endif // GRAPHICSCONVERTER_H