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