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