1 | // $Id: SVN.h 91 2006-03-23 22:56:17Z jari $ |
---|
2 | |
---|
3 | /* |
---|
4 | Copyright (C) 2006 Jari Häkkinen |
---|
5 | |
---|
6 | This file is part of svnstat, http://lev.thep.lu.se/trac/svnstat |
---|
7 | |
---|
8 | svnstat is free software; you can redistribute it and/or modify it |
---|
9 | under the terms of the GNU General Public License as published by |
---|
10 | the Free Software Foundation; either version 2 of the License, or |
---|
11 | (at your option) any later version. |
---|
12 | |
---|
13 | svnstat is distributed in the hope that it will be useful, but |
---|
14 | WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
16 | General Public License for more details. |
---|
17 | |
---|
18 | You should have received a copy of the GNU General Public License |
---|
19 | along with this program; if not, write to the Free Software |
---|
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
---|
21 | 02111-1307, USA. |
---|
22 | */ |
---|
23 | |
---|
24 | #ifndef _theplu_svnstat_svn_ |
---|
25 | #define _theplu_svnstat_svn_ |
---|
26 | |
---|
27 | #include <stdexcept> |
---|
28 | |
---|
29 | #include <apr_allocator.h> |
---|
30 | #include <svn_client.h> |
---|
31 | #include <svn_wc.h> |
---|
32 | |
---|
33 | namespace theplu { |
---|
34 | namespace svnstat { |
---|
35 | |
---|
36 | class Directory; |
---|
37 | |
---|
38 | /// |
---|
39 | /// If something goes wrong in the use of the SVN class, a |
---|
40 | /// SVNException is thrown. |
---|
41 | /// |
---|
42 | struct SVNException : public std::runtime_error |
---|
43 | { inline SVNException(const std::string& msg) : runtime_error(msg) {} }; |
---|
44 | |
---|
45 | /// |
---|
46 | /// The SVN class is a front end to the subversion API. |
---|
47 | /// |
---|
48 | /// SVN provides one single global access point to the underlying |
---|
49 | /// subversion API and makes sure that there is only one point of |
---|
50 | /// access to the binary. |
---|
51 | /// |
---|
52 | /// @see Design Patterns (the singleton pattern). Subversion API |
---|
53 | /// documents. |
---|
54 | /// |
---|
55 | class SVN { |
---|
56 | public: |
---|
57 | |
---|
58 | enum vc_status { |
---|
59 | unversioned=0, |
---|
60 | uptodate, |
---|
61 | unresolved |
---|
62 | }; |
---|
63 | |
---|
64 | /// |
---|
65 | /// @brief The destructor. |
---|
66 | /// |
---|
67 | ~SVN(void); |
---|
68 | |
---|
69 | /// |
---|
70 | /// @brief Get an instance of SVN. |
---|
71 | /// |
---|
72 | /// @throw Throws a SVNException if one is received from the |
---|
73 | /// underlying constructor call. |
---|
74 | /// |
---|
75 | /// @todo Make sure that the underlying constructor performs |
---|
76 | /// proper cleanup before throwing an exception. |
---|
77 | /// |
---|
78 | static SVN* instance(void) |
---|
79 | { if (!instance_) instance_=new SVN; return instance_; } |
---|
80 | |
---|
81 | /// |
---|
82 | /// @throws SCNException if access setup fails. |
---|
83 | /// |
---|
84 | void setup_wc_adm_access(const std::string& path); |
---|
85 | |
---|
86 | /// |
---|
87 | /// @brief Check if entry \a path is under version control |
---|
88 | /// |
---|
89 | /// @return True if \a path is under version control, false |
---|
90 | /// otherwise. |
---|
91 | /// |
---|
92 | vc_status version_controlled(const std::string& path); |
---|
93 | |
---|
94 | private: |
---|
95 | /// |
---|
96 | /// @brief Constructor |
---|
97 | /// |
---|
98 | /// The only way to create a object of SVN type is by calling |
---|
99 | /// SVN::instance. |
---|
100 | /// |
---|
101 | /// @todo Make sure that proper cleanup is performed before |
---|
102 | /// throwing an exception. |
---|
103 | /// |
---|
104 | SVN(void); |
---|
105 | |
---|
106 | /// |
---|
107 | /// @brief Copy Constructor, not implemented. |
---|
108 | /// |
---|
109 | SVN(const SVN&); |
---|
110 | |
---|
111 | static SVN* instance_; |
---|
112 | |
---|
113 | // subversion API stuff |
---|
114 | svn_wc_adm_access_t* adm_access_; |
---|
115 | apr_allocator_t* allocator_; |
---|
116 | svn_client_ctx_t* context_; |
---|
117 | apr_pool_t* pool_; |
---|
118 | }; |
---|
119 | |
---|
120 | }} // end of namespace svnstat and namespace theplu |
---|
121 | |
---|
122 | #endif |
---|