]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/Kernel.h
Overhaul the branches code.
[lyx.git] / src / frontends / controllers / Kernel.h
1 // -*- C++ -*-
2 /**
3  * \file Kernel.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
12 #ifndef KERNEL_H
13 #define KERNEL_H
14
15 #include <string>
16
17
18 class Buffer;
19 class BufferView;
20 class FuncRequest;
21 class LyXView;
22
23
24 /** \c Kernel is a wrapper making the LyX kernel available to the dialog.
25  * (Ie, it provides an interface to the Model part of the Model-Controller-
26  *  View split.
27  *  In an ideal world, it will shrink as more info is passed to the
28  *  Dialog::show() and Dialog::update() methods.
29  */
30 class Kernel {
31 public:
32         /// \param lv is the access point for the dialog to the LyX kernel.
33         Kernel(LyXView & lv);
34
35         /** This method is the primary puypose of the class. It provides
36          *  the "gateway" by which the dialog can send a request (of a
37          *  change in the data, for more information) to the kernel.
38          *  \param fr is the encoding of the request.
39          *  \param verbose is set to true if the completed action should
40          *  be displayed in the minibuffer.
41          */
42         void dispatch(FuncRequest const & fr, bool verbose = false) const;
43
44         /** The dialog has received a request from the user
45          *  (who pressed the "Restore" buuton) to update contents.
46          *  It must, therefore, ask the kernel to provide this information.
47          *  \param name is used to identify the dialog to the kernel.
48          */
49         void updateDialog(std::string const & name) const;
50
51         /** A request from the Controller that future changes to the data
52          *  stored by the dialog are not applied to the inset currently
53          *  connected to the dialog. Instead, they will be used to generate
54          *  a new inset at the cursor position.
55          *  \param name is used to identify the dialog to the kernel.
56          */
57         void disconnect(std::string const & name) const;
58
59         /** \name Kernel Wrappers
60          *  Simple wrapper functions to Buffer methods.
61          */
62         //@{
63         bool isBufferAvailable() const;
64         bool isBufferReadonly() const;
65         std::string const bufferFilepath() const;
66         //@}
67
68         /** \enum DocTypes used to flag the different kinds of buffer
69          *  without making the kernel header files available to the
70          *  dialog's Controller or View.
71          */
72         enum DocTypes {
73                 LATEX,
74                 LITERATE,
75                 LINUXDOC,
76                 DOCBOOK
77         };
78         /// The type of the current buffer.
79         DocTypes docType() const;
80
81
82         /** \name Kernel Nasties
83          *  Unpleasantly public internals of the LyX kernel.
84          *  We should aim to reduce/remove these from the interface.
85          */
86         //@{
87         LyXView & lyxview() { return lyxview_; }
88         LyXView const & lyxview() const { return lyxview_; }
89
90         Buffer & buffer();
91         Buffer const & buffer() const;
92
93         BufferView * bufferview();
94         BufferView const * bufferview() const;
95         //@}
96
97 private:
98         LyXView & lyxview_;
99 };
100
101
102 #endif // KERNEL_H