]> git.lyx.org Git - lyx.git/blob - src/vc-backend.h
ws change
[lyx.git] / src / vc-backend.h
1 // -*- C++ -*-
2 /**
3  * \file vc-backend.h
4  * Copyright 1995-2002 the LyX Team
5  * Read the file COPYING
6  *
7  * \author Lars Gullik Bjønnes
8  */
9
10
11 #ifndef VC_BACKEND_H
12 #define VC_BACKEND_H
13
14 #ifdef __GNUG__
15 #pragma interface
16 #endif
17
18 #include "LString.h"
19
20 class Buffer;
21
22 /// A simple version control system interface
23 class VCS {
24 public:
25         /// the status of the managed file
26         enum VCStatus {
27                 UNLOCKED,
28                 LOCKED
29         };
30
31         virtual ~VCS() {}
32
33         /// register a file for version control
34         virtual void registrer(string const & msg) = 0;
35         /// check in the current revision
36         virtual void checkIn(string const & msg) = 0;
37         /// check out for editing
38         virtual void checkOut() = 0;
39         /// revert current edits
40         virtual void revert() = 0;
41         /// FIXME
42         virtual void undoLast() = 0;
43         /**
44          * getLog - read the revision log into the given file
45          * @param fname file name to read into
46          */
47         virtual void getLog(string const &) = 0;
48         /// return the current version description
49         virtual string const versionString() const = 0;
50         /// return the current version
51         string const & version() const {
52                 return version_;
53         }
54         /// return the user who has locked the file
55         string const & locker() const { return locker_; }
56         /// set the owning buffer
57         void owner(Buffer * b) { owner_ = b; }
58         /// return the owning buffer
59         Buffer * owner() const { return owner_; }
60         /// return the lock status of this file
61         VCStatus status() const { return vcstatus; }
62 protected:
63         /// parse information from the version file
64         virtual void scanMaster() = 0;
65
66         /**
67          * doVCCommand - call out to the version control utility
68          * @param cmd the command to execute
69          * @param path the path from which to execute
70          * @return exit status
71          */
72         static int doVCCommand(string const & cmd, string const & path);
73
74         /**
75          * The master VC file. For RCS this is *,v or RCS/ *,v. master should
76          * have full path.
77          */
78         string master_;
79
80         /// The status of the VC controlled file.
81         VCStatus vcstatus;
82
83         /**
84          * The version of the VC file. I am not sure if this can be a
85          * string or if it must be a float/int.
86          */
87         string version_;
88
89         /// The user currently keeping the lock on the VC file.
90         string locker_;
91         /// The buffer using this VC
92         Buffer * owner_;
93 };
94
95
96 ///
97 class RCS : public VCS {
98 public:
99
100         explicit
101         RCS(string const & m);
102
103         /// return the revision file for the given file, if found
104         static string const find_file(string const & file);
105
106         static void retrieve(string const & file);
107
108         virtual void registrer(string const & msg);
109
110         virtual void checkIn(string const & msg);
111
112         virtual void checkOut();
113
114         virtual void revert();
115
116         virtual void undoLast();
117
118         virtual void getLog(string const &);
119
120         virtual string const versionString() const {
121                 return "RCS: " + version_;
122         }
123
124 protected:
125         virtual void scanMaster();
126 };
127
128
129 ///
130 class CVS : public VCS {
131 public:
132         ///
133         explicit
134         CVS(string const & m, string const & f);
135
136         /// return the revision file for the given file, if found
137         static string const find_file(string const & file);
138
139         virtual void registrer(string const & msg);
140
141         virtual void checkIn(string const & msg);
142
143         virtual void checkOut();
144
145         virtual void revert();
146
147         virtual void undoLast();
148
149         virtual void getLog(string const &);
150
151         virtual string const versionString() const {
152                 return "CVS: " + version_;
153         }
154
155 protected:
156         virtual void scanMaster();
157
158 private:
159         string file_;
160 };
161 #endif // VCBACKEND_H