Ignore:
Timestamp:
Oct 14, 2007, 12:20:17 AM (14 years ago)
Author:
Peter Johansson
Message:

fixes #272 in trunk and also #211 - split stats class into inherited and base class

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/lib/ClassicStats.h

    r482 r487  
    1 #ifndef _theplu_svndigest_stats_
    2 #define _theplu_svndigest_stats_
     1#ifndef _theplu_svndigest_classic_stats_
     2#define _theplu_svndigest_classic_stats_
    33
    44// $Id$
     
    2727*/
    2828
    29 #include "Parser.h"
    30 
    31 #include <subversion-1/svn_types.h>
    32 
    33 #include <map>
    34 #include <istream>
    35 #include <set>
    36 #include <string>
    37 #include <vector>
     29#include "Stats.h"
    3830
    3931namespace theplu{
     
    4335  /// Class taking care of statistics from svn.
    4436  ///
    45   class Stats
     37  class ClassicStats : public Stats
    4638  {
    4739  public:
     
    4941    /// @brief Default Constructor
    5042    ///
    51     explicit Stats(const std::string& path);
    52 
    53     ///
    54     /// @return set of authors
    55     ///
    56     inline const std::set<std::string>& authors(void) const { return authors_; }
     43    explicit ClassicStats(const std::string& path);
    5744
    5845    ///
     
    9077
    9178    ///
    92     ///
    93     ///
    94     inline u_int last_changed_rev(void) const { return last_changed_rev_; }
    95 
    96     ///
    9779    ///
    9880    ///
     
    10587    { return accumulated(total_, user).back(); }
    10688
    107     /**
    108        Load object from a stream.
    109        
    110        \return true if successful
    111      */
    112     bool load_cache(std::istream&);
    113 
    114     void parse(const std::string&);
    115 
    116     ///
    117     /// Create statistics graph.
    118     ///
    119     std::string plot(const std::string&, const std::string&) const;
    120 
    121     ///
    122     /// Create statistics graph.
    123     ///
    124     void plot_init(const std::string& output) const;
    125 
    12689    ///
    12790    /// Summary plot for the first page
    12891    ///
    12992    void plot_summary(const std::string& output) const;
    130 
    131     /**
    132      */
    133     void print(std::ostream&) const;
    134 
    135     ///
    136     /// @brief Clear all statistics
    137     ///
    138     inline void reset(void)
    139     {
    140       code_.clear(); comments_.clear(); empty_.clear(); total_.clear();
    141       authors_.clear();
    142     }
    143 
    144     ///
    145     /// \return latest revision for whole project
    146     ///
    147     inline u_int revision(void) const { return revision_; }
    14893
    14994    ///
     
    156101    /// @return resulting Stats
    157102    ///
    158     Stats& operator+=(const Stats&);
     103    ClassicStats& operator+=(const ClassicStats&);
    159104
    160105  private:
     
    164109    typedef Map_::const_iterator MapConstIter_;
    165110
    166     ///
    167     /// Copy constructor (not implemented)
    168     ///
    169     Stats(const Stats& other);
     111    /// using compiler generated copy
     112    //ClassicStats(const ClassicStats& other);
    170113
    171114    ///
     
    186129             const Parser::line_type&);
    187130
     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
    188157    // Change this string if cache format is changed in such a way
    189158    // that all old cache files are obsolete.
    190     inline std::string end_of_cache(void) const {return "END OF OK CACHE FILE";}
    191     inline std::string code_cache(void) const {return "CACHE CODE";}
    192     inline std::string comments_cache(void) const {return "CACHE COMMENTS";}
    193     inline std::string empty_cache(void) const {return "CACHE EMPTY";}
    194     inline std::string total_cache(void) const {return "CACHE TOTAL";}
     159    inline std::string end_of_cache(void) const
     160    {return "END OF OK CACHE FILE VERSION 2";}
    195161   
    196162
     163    std::vector<u_int> vector(std::string type, std::string user) const;
    197164    /**
    198165       Load map from stream
     
    200167    void load(std::istream&, Map_&);
    201168
    202     void print(std::ostream& os, const Map_& map) const;
     169    void do_print(std::ostream& os, const Map_& map) const;
    203170
    204     svn_revnum_t revision_; // Should be the latest revision for whole project
    205     svn_revnum_t last_changed_rev_; // Should be the latest revision for file
    206 
    207     std::set<std::string> authors_;
    208171    Map_ code_;
    209172    Map_ comments_;
Note: See TracChangeset for help on using the changeset viewer.