]> git.lyx.org Git - lyx.git/blob - src/graphics/GraphicsConverter.h
ws changes
[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 #ifdef __GNUG__
21 #pragma interface
22 #endif
23
24 #include "LString.h"
25 #include <boost/signals/signal1.hpp>
26 #include <boost/scoped_ptr.hpp>
27 #include <boost/utility.hpp>
28
29 namespace grfx {
30
31 class Converter : boost::noncopyable {
32 public:
33         /// Can the conversion be performed?
34         static bool isReachable(string const & from_format_name,
35                                 string const & to_format_name);
36
37         /** One Converter per conversion ensures that the (hidden) signal
38          *  is always connected to the expected slot.
39          */
40         Converter(string const & from_file,   string const & to_file_base,
41                   string const & from_format, string const & to_format);
42
43         /// Define an empty d-tor out-of-line to keep boost::scoped_ptr happy.
44         ~Converter();
45
46         /// We are explicit about when we begin the conversion process.
47         void startConversion() const;
48
49         /** Connect and you'll be informed when the conversion process has
50          *  finished.
51          *  If the conversion is succesful, then the listener is passed \c true.
52          */
53         typedef boost::signal1<void, bool>::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         string 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 grfx
73
74 #endif // GRAPHICSCONVERTER_H