]> git.lyx.org Git - lyx.git/blob - src/bufferlist.h
remove unused stuff
[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 <string>
18 #include <vector>
19
20
21 namespace lyx {
22
23 class Buffer;
24 class OutputParams;
25
26 /**
27  * The class holds all all open buffers, and handles construction
28  * and deletions of new ones.
29  */
30 class BufferList : boost::noncopyable {
31 public:
32         typedef std::vector<Buffer *>::iterator iterator;
33         typedef std::vector<Buffer *>::const_iterator const_iterator;
34
35 public:
36         BufferList();
37
38         iterator begin();
39         const_iterator begin() const;
40
41         iterator end();
42         const_iterator end() const;
43
44         /// write all buffers, asking the user, returns false if cancelled
45         bool quitWriteAll();
46
47         /// create a new buffer
48         Buffer * newBuffer(std::string const & s, bool ronly = false);
49
50         /// delete a buffer
51         void release(Buffer * b);
52
53         /// Close all open buffers.
54         void closeAll();
55
56         /// returns a vector with all the buffers filenames
57         std::vector<std::string> const getFileNames() const;
58
59         /// FIXME
60         void updateIncludedTeXfiles(std::string const &, OutputParams const &);
61
62         /// emergency save for all buffers
63         void emergencyWriteAll();
64
65         /// close buffer. Returns false if cancelled by user
66         bool close(Buffer * buf, bool ask);
67
68         /// return true if no buffers loaded
69         bool empty() const;
70
71         /// return head of buffer list if any
72         Buffer * first();
73
74         /// return back of buffer list if any
75         Buffer * last();
76
77         /// returns true if the buffer exists already
78         bool exists(std::string const &) const;
79
80         /// returns true if the buffer is loaded
81         bool isLoaded(Buffer const * b) const;
82
83         /// returns a pointer to the buffer with the given name.
84         Buffer * getBuffer(std::string const &);
85         /// returns a pointer to the buffer with the given number.
86         Buffer * getBuffer(unsigned int);
87         /// returns a pointer to the buffer whose temppath matches the string
88         Buffer * getBufferFromTmp(std::string const &);
89
90         /** returns a pointer to the buffer that follows argument in
91          * buffer list. The buffer following the last in list is the
92          * first one.
93          */
94         Buffer * next(Buffer const *) const;
95
96         /** returns a pointer to the buffer that precedes argument in
97          * buffer list. The buffer preceding the first in list is the
98          * last one.
99          */
100         Buffer * previous(Buffer const *) const;
101
102         /// reset current author for all buffers
103         void setCurrentAuthor(std::string const & name, std::string const & email);
104
105 private:
106         /// ask to save a buffer on quit, returns false if should cancel
107         bool quitWriteBuffer(Buffer * buf);
108
109         typedef std::vector<Buffer *> BufferStorage;
110
111         /// storage of all buffers
112         BufferStorage bstore;
113
114         /// save emergency file for the given buffer
115         void emergencyWrite(Buffer * buf);
116 };
117
118 /// Implementation is in lyx_main.C
119 extern BufferList & theBufferList();
120
121
122 } // namespace lyx
123
124 #endif // BUFFERLIST_H