]> git.lyx.org Git - lyx.git/blob - src/BufferList.h
LYX_CXX_GLOBAL_CSTD is not really useful anymore
[lyx.git] / src / BufferList.h
1 // -*- C++ -*-
2 /**
3  * \file BufferList.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef BUFFER_LIST_H
13 #define BUFFER_LIST_H
14
15 #include "support/docstring.h"
16
17 #include <vector>
18
19
20 namespace lyx {
21
22 class Buffer;
23 class OutputParams;
24
25 /**
26  * The class holds all all open buffers, and handles construction
27  * and deletions of new ones.
28  */
29 class BufferList {
30 public:
31         typedef std::vector<Buffer *>::iterator iterator;
32         typedef std::vector<Buffer *>::const_iterator const_iterator;
33
34 public:
35         BufferList();
36
37         iterator begin();
38         const_iterator begin() const;
39
40         iterator end();
41         const_iterator end() const;
42
43         /// create a new buffer
44         Buffer * newBuffer(std::string const & s, bool ronly = false);
45
46         /// delete a buffer
47         void release(Buffer * b);
48
49         /// Close all open buffers.
50         void closeAll();
51
52         /// returns a vector with all the buffers filenames
53         std::vector<std::string> const getFileNames() const;
54
55         /// FIXME
56         void updateIncludedTeXfiles(std::string const &, OutputParams const &);
57
58         /// emergency save for all buffers
59         void emergencyWriteAll();
60
61         /// return true if no buffers loaded
62         bool empty() const;
63
64         /// return head of buffer list if any
65         Buffer * first();
66
67         /// return back of buffer list if any
68         Buffer * last();
69
70         /// returns true if the buffer exists already
71         bool exists(std::string const &) const;
72
73         /// returns true if the buffer is loaded
74         bool isLoaded(Buffer const * b) const;
75
76         /// return index of named buffer in buffer list
77         int bufferNum(std::string const & name) const;
78         /// returns a pointer to the buffer with the given name.
79         Buffer * getBuffer(std::string const &);
80         /// returns a pointer to the buffer with the given number.
81         Buffer * getBuffer(unsigned int);
82         /// returns a pointer to the buffer whose temppath matches the string
83         Buffer * getBufferFromTmp(std::string const &);
84
85         /** returns a pointer to the buffer that follows argument in
86          * buffer list. The buffer following the last in list is the
87          * first one.
88          */
89         Buffer * next(Buffer const *) const;
90
91         /** returns a pointer to the buffer that precedes argument in
92          * buffer list. The buffer preceding the first in list is the
93          * last one.
94          */
95         Buffer * previous(Buffer const *) const;
96
97         /// reset current author for all buffers
98         void setCurrentAuthor(docstring const & name, docstring const & email);
99
100 private:
101         /// noncopiable
102         BufferList(BufferList const &);
103         void operator=(BufferList const &);
104
105         typedef std::vector<Buffer *> BufferStorage;
106
107         /// storage of all buffers
108         BufferStorage bstore;
109
110         /// save emergency file for the given buffer
111         void emergencyWrite(Buffer * buf);
112 };
113
114 /// Implementation is in LyX.cpp
115 extern BufferList & theBufferList();
116
117
118 } // namespace lyx
119
120 #endif // BUFFERLIST_H