]> git.lyx.org Git - lyx.git/blob - src/LyXVC.h
337f797293314e379d2413fe5a95291ee851e60c
[lyx.git] / src / LyXVC.h
1 // -*- C++ -*-
2 /**
3  * \file LyXVC.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 LYX_VC_H
13 #define LYX_VC_H
14
15 #include <boost/scoped_ptr.hpp>
16
17 #include <string>
18
19
20 namespace lyx {
21
22 namespace support { class FileName; }
23
24 class VCS;
25 class Buffer;
26
27 /** Version Control for LyX.
28     This is the class giving the verison control features to LyX. It is
29     intended to support different kinds of version control, but at this point
30     we will only support RCS. Later CVS is a likely candidate for support.
31     The support in LyX is based loosely upon the version control in GNU Emacs,
32     but is not as extensive as that one. See examples/VC.lyx for a simple
33     tutorial and manual for the use of the version control system in LyX.
34
35     LyXVC use this algorithm when it searches for VC files:
36     for RCS it searches for <filename>,v and RCS/<filename>,v similar
37     should be done for CVS. By doing this there doesn't need to be any
38     special support for VC in the lyx format, and this is especially good
39     when the lyx format will be a subset of LaTeX.
40 */
41 class LyXVC {
42 public:
43         ///
44         LyXVC();
45         ///
46         ~LyXVC();
47         /** Not a good name perhaps. This function should be called whenever
48           LyX loads a file. This function then checks for a master VC file
49           (for RCS this is *,v or RCS/ *,v) if this file is found, the loaded
50           file is assumed to be under controll by VC (only RCS so far), and
51           the appropiate actions is taken. Returns true if the file is under
52           control by a VCS.
53           */
54         bool file_found_hook(support::FileName const & fn);
55
56         /** This function should be run when a file is requested for loading,
57           but it does not exist. This function will then check for a VC master
58           file with the same name (see above function). If this exists the
59           user should be asked if he/her wants to checkout a version for
60           viewing/editing. Returns true if the file is under control by a VCS
61           and the user wants to view/edit it.
62           */
63         static bool file_not_found_hook(support::FileName const & fn);
64
65         ///
66         void setBuffer(Buffer *);
67
68         /// Register the document as an VC file.
69         void registrer();
70
71         /// Unlock and commit changes.
72         void checkIn();
73         /// Does the current VC supports this operation?
74         bool checkInEnabled();
75
76         /// Lock and prepare to edit document.
77         void checkOut();
78         /// Does the current VC supports this operation?
79         bool checkOutEnabled();
80
81         /// Revert to last version
82         void revert();
83
84         /// Undo last check-in.
85         void undoLast();
86         /// Does the current VC supports this operation?
87         bool undoLastEnabled();
88
89         /**
90          * Generate a log file and return the filename.
91          * It is the caller's responsibility to remove the
92          * file after use.
93          */
94         const std::string getLogFile() const;
95
96         ///
97         void toggleReadOnly();
98
99         /// Is the document under administration by RCS?
100         bool inUse();
101
102         /// Returns the version number.
103         //std::string const & version() const;
104         /// Returns the version number.
105         std::string const versionString() const;
106
107         /// Returns the userid of the person who has locked the doc.
108         std::string const & locker() const;
109
110 private:
111         ///
112         Buffer * owner_;
113
114         ///
115         boost::scoped_ptr<VCS> vcs;
116 };
117
118
119 } // namespace lyx
120
121 #endif