]> git.lyx.org Git - lyx.git/blob - src/vc-backend.h
dont use pragma impementation and interface anymore
[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         /**
63          * doVCCommand - call out to the version control utility
64          * @param cmd the command to execute
65          * @param path the path from which to execute
66          * @return exit status
67          */
68         static int doVCCommand(string const & cmd, string const & path);
69
70         /**
71          * The master VC file. For RCS this is *,v or RCS/ *,v. master should
72          * have full path.
73          */
74         string master_;
75
76         /// The status of the VC controlled file.
77         VCStatus vcstatus;
78
79         /**
80          * The version of the VC file. I am not sure if this can be a
81          * string or if it must be a float/int.
82          */
83         string version_;
84
85         /// The user currently keeping the lock on the VC file.
86         string locker_;
87         /// The buffer using this VC
88         Buffer * owner_;
89 };
90
91
92 ///
93 class RCS : public VCS {
94 public:
95
96         explicit
97         RCS(string const & m);
98
99         /// return the revision file for the given file, if found
100         static string const find_file(string const & file);
101
102         static void retrieve(string const & file);
103
104         virtual void registrer(string const & msg);
105
106         virtual void checkIn(string const & msg);
107
108         virtual void checkOut();
109
110         virtual void revert();
111
112         virtual void undoLast();
113
114         virtual void getLog(string const &);
115
116         virtual string const versionString() const {
117                 return "RCS: " + version_;
118         }
119
120 protected:
121         virtual void scanMaster();
122 };
123
124
125 ///
126 class CVS : public VCS {
127 public:
128         ///
129         explicit
130         CVS(string const & m, string const & f);
131
132         /// return the revision file for the given file, if found
133         static string const find_file(string const & file);
134
135         virtual void registrer(string const & msg);
136
137         virtual void checkIn(string const & msg);
138
139         virtual void checkOut();
140
141         virtual void revert();
142
143         virtual void undoLast();
144
145         virtual void getLog(string const &);
146
147         virtual string const versionString() const {
148                 return "CVS: " + version_;
149         }
150
151 protected:
152         virtual void scanMaster();
153
154 private:
155         string file_;
156 };
157 #endif // VCBACKEND_H