]> git.lyx.org Git - lyx.git/blob - src/LyXVC.h
Fixed some lines that were too long. It compiled afterwards.
[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 buffer(Buffer *);
67
68         /// Register the document as an VC file.
69         void registrer();
70
71         /// Unlock and commit changes.
72         void checkIn();
73
74         /// Lock and prepare to edit document.
75         void checkOut();
76
77         /// Revert to last version
78         void revert();
79
80         /// Undo last check-in.
81         void undoLast();
82
83         /**
84          * Generate a log file and return the filename.
85          * It is the caller's responsibility to unlink the
86          * file after use.
87          */
88         const std::string getLogFile() const;
89
90         ///
91         void toggleReadOnly();
92
93         /// Is the document under administration by RCS?
94         bool inUse();
95
96         /// Returns the version number.
97         //std::string const & version() const;
98         /// Returns the version number.
99         std::string const versionString() const;
100
101         /// Returns the userid of the person who has locked the doc.
102         std::string const & locker() const;
103
104 private:
105         ///
106         Buffer * owner_;
107
108         ///
109         boost::scoped_ptr<VCS> vcs;
110 };
111
112
113 } // namespace lyx
114
115 #endif