source: trunk/lib/ClassicStats.h @ 519

Last change on this file since 519 was 519, checked in by Jari Häkkinen, 14 years ago

trac moved to new location.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.1 KB
RevLine 
[487]1#ifndef _theplu_svndigest_classic_stats_
2#define _theplu_svndigest_classic_stats_
[165]3
[84]4// $Id: ClassicStats.h 519 2007-12-23 20:14:50Z jari $
[14]5
[84]6/*
7  Copyright (C) 2005 Peter Johansson
8  Copyright (C) 2006 Jari Häkkinen, Peter Johansson
[408]9  Copyright (C) 2007 Peter Johansson
[84]10
[519]11  This file is part of svndigest, http://trac.thep.lu.se/svndigest
[84]12
[149]13  svndigest is free software; you can redistribute it and/or modify it
[84]14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation; either version 2 of the License, or
16  (at your option) any later version.
17
[149]18  svndigest is distributed in the hope that it will be useful, but
[84]19  WITHOUT ANY WARRANTY; without even the implied warranty of
[149]20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
[84]21  General Public License for more details.
22
23  You should have received a copy of the GNU General Public License
24  along with this program; if not, write to the Free Software
25  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26  02111-1307, USA.
27*/
28
[487]29#include "Stats.h"
[118]30
[14]31namespace theplu{
[149]32namespace svndigest{
[14]33
34  ///
35  /// Class taking care of statistics from svn.
36  ///
[487]37  class ClassicStats : public Stats
[14]38  {
39  public:
40    ///
41    /// @brief Default Constructor
[34]42    ///
[487]43    explicit ClassicStats(const std::string& path);
[34]44
[60]45    ///
[118]46    ///
47    ///
48    inline u_int code(void) const { return accumulated(code_).back(); }
49
50    ///
51    ///
52    ///
53    inline u_int code(const std::string& user) const 
54    { return accumulated(code_, user).back(); }
55
56    ///
57    ///
58    ///
59    inline u_int comments(void) const { return accumulated(comments_).back(); }
60
61    ///
62    ///
63    ///
64    inline u_int comments(const std::string& user) const 
65    { return accumulated(comments_, user).back(); }
66
67    ///
[202]68    ///
[118]69    ///
[202]70    inline u_int empty(void) const { return accumulated(empty_).back(); }
71
[118]72    ///
[202]73    ///
74    ///
75    inline u_int empty(const std::string& user) const 
76    { return accumulated(empty_, user).back(); }
77
78    ///
[345]79    ///
80    ///
81    inline u_int lines(void) const { return accumulated(total_).back(); }
82
83    ///
84    ///
85    ///
86    inline u_int lines(const std::string& user) const 
87    { return accumulated(total_, user).back(); }
88
[23]89    ///
[345]90    /// Summary plot for the first page
91    ///
92    void plot_summary(const std::string& output) const;
93
94    ///
[118]95    ///
[112]96    ///
[198]97    inline std::vector<u_int> total(const std::string& user) const 
98    { return accumulated(total_, user); }
99
[14]100    ///
101    /// @return resulting Stats
102    ///
[487]103    ClassicStats& operator+=(const ClassicStats&);
[14]104
105  private:
[118]106    // Peter, if the vector is sparse make it a map
107    typedef std::map<std::string, std::vector<u_int> > Map_;
108    typedef Map_::iterator MapIter_;
109    typedef Map_::const_iterator MapConstIter_;
110
[487]111    /// using compiler generated copy
112    //ClassicStats(const ClassicStats& other);
[14]113
[23]114    ///
115    /// @return accumulated vector of total
116    ///
[118]117    std::vector<u_int> accumulated(const Map_&) const;
[23]118
119    ///
120    /// @return accumulated vector of stats_[user]
121    ///
[118]122    std::vector<u_int> accumulated(const Map_&, 
123                                   const std::string& user) const;
[23]124
[60]125    ///
126    /// @brief adding a line to user from revision to the stats
127    ///
[118]128    void add(const std::string& user, const u_int& revision,
[138]129             const Parser::line_type&); 
[60]130
[487]131    /**
132       Load object from a stream.
133       
134       \return true if successful
135     */
136    bool do_load_cache(std::istream&);
137
138    void do_parse(const std::string&);
139
140    ///
141    /// Create statistics graph.
142    ///
143    std::string do_plot(const std::string&, const std::string&) const;
144
145    /**
146     */
147    void do_print(std::ostream&) const;
148
149    ///
150    /// @brief Clear all statistics
151    ///
152    inline void do_reset(void) 
153    { 
154      code_.clear(); comments_.clear(); empty_.clear(); total_.clear(); 
155    }
156
[482]157    // Change this string if cache format is changed in such a way
158    // that all old cache files are obsolete.
[487]159    inline std::string end_of_cache(void) const 
160    {return "END OF OK CACHE FILE VERSION 2";} 
[482]161   
[41]162
[487]163    std::vector<u_int> vector(std::string type, std::string user) const;
[468]164    /**
165       Load map from stream
166     */
167    void load(std::istream&, Map_&);
168
[487]169    void do_print(std::ostream& os, const Map_& map) const;
[454]170
[118]171    Map_ code_;
172    Map_ comments_;
[202]173    Map_ empty_;
[118]174    Map_ total_;
[14]175  };
[149]176}} // end of namespace svndigest end of namespace theplu
[14]177
[71]178#endif
Note: See TracBrowser for help on using the repository browser.