]> git.lyx.org Git - lyx.git/blob - src/bufferlist.h
84f9a8047ed5e30b52ff3d00ad056c97c4ddeeb4
[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 <boost/utility.hpp>
16
17 #include <vector>
18
19 class Buffer;
20 class LatexRunParams;
21
22 /**
23  * The class holds all all open buffers, and handles construction
24  * and deletions of new ones.
25  */
26 class BufferList : boost::noncopyable {
27 public:
28         BufferList();
29
30         /// write all buffers, asking the user, returns false if cancelled
31         bool quitWriteAll();
32
33         /// create a new buffer
34         Buffer * newBuffer(std::string const & s, bool ronly = false);
35
36         /// delete a buffer
37         void release(Buffer * b);
38
39         /// Close all open buffers.
40         void closeAll();
41
42         /// returns a vector with all the buffers filenames
43         std::vector<std::string> const getFileNames() const;
44
45         /// FIXME
46         void updateIncludedTeXfiles(std::string const &, LatexRunParams const &);
47
48         /// emergency save for all buffers
49         void emergencyWriteAll();
50
51         /// close buffer. Returns false if cancelled by user
52         bool close(Buffer * buf, bool ask);
53
54         /// return true if no buffers loaded
55         bool empty() const;
56
57         /// return head of buffer list if any
58         Buffer * first();
59
60         /// returns true if the buffer exists already
61         bool exists(std::string const &) const;
62
63         /// returns true if the buffer is loaded
64         bool isLoaded(Buffer const * b) const;
65
66         /// returns a pointer to the buffer with the given name.
67         Buffer * getBuffer(std::string const &);
68         /// returns a pointer to the buffer with the given number.
69         Buffer * getBuffer(unsigned int);
70
71         /// reset current author for all buffers
72         void setCurrentAuthor(std::string const & name, std::string const & email);
73
74 private:
75         /// ask to save a buffer on quit, returns false if should cancel
76         bool quitWriteBuffer(Buffer * buf);
77
78         typedef std::vector<Buffer *> BufferStorage;
79
80         /// storage of all buffers
81         BufferStorage bstore;
82
83         /// save emergency file for the given buffer
84         void emergencyWrite(Buffer * buf);
85 };
86
87 #endif // BUFFERLIST_H