source: trunk/lib/SVNlog.h @ 759

Last change on this file since 759 was 759, checked in by Peter Johansson, 12 years ago

Change container in SVNlog to be std::set<Commitment>, in order to
avoid copying in SVNlog::operator+=. Previously we had vector, but the
index had no meaning, in other words, the random access was not used.

refs #74

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.5 KB
Line 
1#ifndef _theplu_svndigest_svnlog_
2#define _theplu_svndigest_svnlog_
3
4// $Id: SVNlog.h 759 2009-01-29 11:51:35Z peter $
5
6/*
7  Copyright (C) 2007 Jari Häkkinen, Peter Johansson
8
9  This file is part of svndigest, http://dev.thep.lu.se/svndigest
10
11  svndigest is free software; you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation; either version 3 of the License, or
14  (at your option) any later version.
15
16  svndigest is distributed in the hope that it will be useful, but
17  WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20
21  You should have received a copy of the GNU General Public License
22  along with svndigest. If not, see <http://www.gnu.org/licenses/>.
23*/
24
25#include "SVN.h"
26
27#include "Commitment.h"
28
29#include <string>
30#include <set>
31
32#include <subversion-1/svn_client.h>
33
34namespace theplu {
35namespace svndigest {
36
37  class SVN;
38
39  /**
40     The SVNlog class is a utility class for taking care of 'svn
41     log' information. An 'svn log' is performed on an item, the
42     log information for each revision is a vector<Commitment>.
43  */
44  class SVNlog {
45  public:
46    /**
47       container used to store log
48     */
49    typedef std::set<Commitment, LessRevision> container;
50
51    /**
52       Default constructor. Creates empty log.
53     */
54    SVNlog(void);
55
56    /**
57       \brief The contructor.
58       
59       The constructor performs an 'svn log' on \a path and
60       stores the information for later access.
61    */
62    explicit SVNlog(const std::string& path);
63
64    /**
65       \brief The destructor.
66    */
67    ~SVNlog(void);
68
69    /**
70       \return Commitments
71    */
72    inline const container& commits(void) const
73    { return lb_.commits; }
74
75    /**
76       \return Commitments
77    */
78    inline container& commits(void)
79    { return lb_.commits; }
80
81    /**
82       \return true if \a author appears in log.
83    */
84    bool exist(std::string author) const;
85
86    /**
87       \return Latest commit
88    */
89    const Commitment& latest_commit(void) const;
90
91    /**
92       \return Latest commit \a author did. If no author is found an
93       empty Commitment (default constructor) is returned.
94    */
95    const Commitment& latest_commit(std::string author) const;
96
97    /**
98     */
99    void swap(SVNlog&);
100   
101  private:
102
103    ///
104    /// @brief Copy Constructor, not implemented.
105    ///
106    // using compiler generated copy constructor
107    //SVNlog(const SVNlog&);
108
109    /**
110       log information is stored in the log_receiver_baton. The
111       information is retrieved with the info_* set of member
112       functions. The struct is filled in the info_receiver function.
113
114       \see info_receiver
115    */
116    struct log_receiver_baton {
117      container commits;
118    } lb_;
119
120    /**
121       info_receiver is the function passed to the underlying
122       subversion API. This function is called by the subversion API
123       for every item matched by the conditions of the API call.
124
125       \see Subversion API documentation
126    */
127    // The return type should be svn_log_message_receiver_t but I
128    // cannot get it to compile. The svn API has a typedef like
129    // typedef svn_error_t*(* svn_log_message_receiver_t)(void *baton,
130    // apr_hash_t *changed_paths, svn_revnum_t revision, const char
131    // *author, const char *date,const char *message, apr_pool_t
132    // *pool) for svn_log_message_receiver_t.
133    static svn_error_t*
134    log_message_receiver(void *baton, apr_hash_t *changed_paths,
135                         svn_revnum_t rev, const char *author, const char *date,
136                         const char *msg, apr_pool_t *pool);
137  };
138
139  /**
140   */
141  SVNlog& operator+=(SVNlog&, const SVNlog&);
142
143}} // end of namespace svndigest and namespace theplu
144
145#endif
Note: See TracBrowser for help on using the repository browser.