source: trunk/lib/Stats.h @ 73

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

Divided Gnuplot class into a basic gnuplot communication class
and a front end class specialized for svnstat.
Added option to plot stats against time or revision.
Removed gnuplot usage of temporary files.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.7 KB
Line 
1//$Id: Stats.h 73 2006-03-04 18:10:07Z jari $
2
3#ifndef _theplu_svnstat_stats_
4#define _theplu_svnstat_stats_
5
6#include <iostream>
7#include <map>
8#include <ostream>
9#include <string>
10#include <vector>
11
12namespace theplu{
13namespace svnstat{
14
15  ///
16  /// Class taking care of statistics from svn.
17  ///
18  class Stats
19  {
20  public:
21    ///
22    /// @brief Default Constructor
23    ///
24    inline Stats(void) {}
25
26    ///
27    /// @return true if file is binary
28    ///
29    bool parse(const std::string&);
30
31    ///
32    /// @brief Print statistics
33    ///
34    void inline print(std::ostream& s, const std::string& name) const
35    { s << "<p><img src='" << plot(name) << "' alt='[plot]' border=0></p>\n"; }
36
37    ///
38    /// @brief Clear all statistics
39    ///
40    inline void reset(void) { map_.clear(); }
41
42    ///
43    /// @return resulting Stats
44    ///
45    Stats& operator+=(const Stats&);
46
47  private:
48    ///
49    /// Copy constructor (not implemented)
50    ///
51    Stats(const Stats& other);
52
53    ///
54    /// @return accumulated vector of total
55    ///
56    std::vector<double> accumulated(void) const;
57
58    ///
59    /// @return accumulated vector of stats_[user]
60    ///
61    std::vector<double> accumulated(const std::string& user) const;
62
63    ///
64    /// @brief adding a line to user from revision to the stats
65    ///
66    void add(const std::string& user, const u_int& revision); 
67
68    std::string plot(const std::string&) const;
69
70    static u_int latest_revision_; // latest revision for whole project
71
72    // Peter, if the vector is sparse make it a map
73    typedef std::map<std::string, std::vector<u_int> > Map_;
74    typedef Map_::iterator MapIter_;
75    typedef Map_::const_iterator MapConstIter_;
76    Map_ map_;
77  };
78}} // end of namespace svnstat end of namespace theplu
79
80#endif
Note: See TracBrowser for help on using the repository browser.