Changeset 118 for trunk/lib/Stats.h


Ignore:
Timestamp:
Jul 3, 2006, 9:44:49 AM (15 years ago)
Author:
Peter Johansson
Message:

fixes #46 #45 #26 #40

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Stats.h

    r112 r118  
    2626#define _theplu_svnstat_stats_
    2727
     28#include "Parser.h"
     29
    2830#include <iostream>
    2931#include <map>
    3032#include <ostream>
     33#include <set>
    3134#include <string>
    3235#include <vector>
     
    4548    ///
    4649    explicit Stats(const std::string& path);
     50
     51    ///
     52    /// @return set of authors
     53    ///
     54    inline const std::set<std::string>& authors(void) const { return authors_; }
     55
     56    ///
     57    ///
     58    ///
     59    inline u_int code(void) const { return accumulated(code_).back(); }
     60
     61    ///
     62    ///
     63    ///
     64    inline u_int code(const std::string& user) const
     65    { return accumulated(code_, user).back(); }
     66
     67    ///
     68    ///
     69    ///
     70    inline u_int comments(void) const { return accumulated(comments_).back(); }
     71
     72    ///
     73    ///
     74    ///
     75    inline u_int comments(const std::string& user) const
     76    { return accumulated(comments_, user).back(); }
    4777
    4878    ///
     
    6494    /// @brief Clear all statistics
    6595    ///
    66     inline void reset(void) { map_.clear(); }
     96    inline void reset(void)
     97    { code_.clear(); comments_.clear(); total_.clear(); authors_.clear();}
    6798
    6899    ///
     
    72103
    73104    ///
     105    ///
    74106    ///
     107    inline u_int lines(void) const { return accumulated(total_).back(); }
     108
    75109    ///
    76     inline u_int rows(void) const { return accumulated().back(); }
     110    ///
     111    ///
     112    inline u_int lines(const std::string& user) const
     113    { return accumulated(total_, user).back(); }
    77114
    78115    ///
     
    82119
    83120  private:
     121    // Peter, if the vector is sparse make it a map
     122    typedef std::map<std::string, std::vector<u_int> > Map_;
     123    typedef Map_::iterator MapIter_;
     124    typedef Map_::const_iterator MapConstIter_;
     125
    84126    ///
    85127    /// Copy constructor (not implemented)
     
    90132    /// @return accumulated vector of total
    91133    ///
    92     std::vector<u_int> accumulated(void) const;
     134    std::vector<u_int> accumulated(const Map_&) const;
    93135
    94136    ///
    95137    /// @return accumulated vector of stats_[user]
    96138    ///
    97     std::vector<u_int> accumulated(const std::string& user) const;
     139    std::vector<u_int> accumulated(const Map_&,
     140                                   const std::string& user) const;
    98141
    99142    ///
    100143    /// @brief adding a line to user from revision to the stats
    101144    ///
    102     void add(const std::string& user, const u_int& revision);
     145    void add(const std::string& user, const u_int& revision,
     146             const Parser::line_type);
    103147
    104148
     
    106150    u_int last_changed_rev_; // Should be the latest revision for file
    107151
    108     // Peter, if the vector is sparse make it a map
    109     typedef std::map<std::string, std::vector<u_int> > Map_;
    110     typedef Map_::iterator MapIter_;
    111     typedef Map_::const_iterator MapConstIter_;
    112     Map_ map_;
     152    std::set<std::string> authors_;
     153    Map_ code_;
     154    Map_ comments_;
     155    Map_ total_;
    113156  };
    114157}} // end of namespace svnstat end of namespace theplu
Note: See TracChangeset for help on using the changeset viewer.