source: trunk/lib/Stats.h @ 60

Last change on this file since 60 was 60, checked in by Peter Johansson, 16 years ago

plotting vs date rather than revision

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1//$Id: Stats.h 60 2006-01-16 10:03:04Z peter $
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  class Gnuplot;
16
17  ///
18  /// Class taking care of statistics from svn.
19  ///
20  class Stats
21  {
22  public:
23    ///
24    /// @brief Default Constructor
25    ///
26    inline Stats(void) {}
27
28    ///
29    /// @return true if file is binary
30    ///
31    bool parse(const std::string&, const bool);
32
33    ///
34    /// @brief Print statistics
35    ///
36    void inline print(std::ostream& s) const
37    { s << "<p><img src='" << plot() << "' alt='[plot]' border=0></p>\n"; }
38
39    ///
40    /// @brief Clear all statistics
41    ///
42    inline void reset(void) { map_.clear(); }
43
44    ///
45    /// @return resulting Stats
46    ///
47    Stats& operator+=(const Stats&);
48
49    ///
50    /// Jari, this is public. Naughty!
51    ///
52    /// @todo Make this non-public. The issues that gnuplot is started
53    /// in cwd, but the main program makes a 'chdir' to another, and
54    /// we cannot get gnuplot to change directory if it is
55    /// private. Some redesign is needed.
56    ///
57    static Gnuplot gnuplot_pipe_;
58
59  private:
60    ///
61    /// Copy constructor (not implemented)
62    ///
63    Stats(const Stats& other);
64
65    ///
66    /// @return accumulated vector of total
67    ///
68    std::vector<double> accumulated(void) const;
69
70    ///
71    /// @return accumulated vector of stats_[user]
72    ///
73    std::vector<double> accumulated(const std::string& user) const;
74
75    ///
76    /// @brief adding a line to user from revision to the stats
77    ///
78    void add(const std::string& user, const u_int& revision); 
79
80    std::string plot(void) const;
81
82    static u_int latest_revision_; // latest rev. for whole project
83
84    // Peter, if the vector is sparse make it a map
85    typedef std::map<std::string, std::vector<u_int> > Map_;
86    typedef Map_::iterator MapIter_;
87    typedef Map_::const_iterator MapConstIter_;
88    Map_ map_;
89  };
90}}
91
92#endif // end of namespace svnstat end of namespace theplu
Note: See TracBrowser for help on using the repository browser.