Changeset 527


Ignore:
Timestamp:
Dec 25, 2007, 6:11:09 AM (16 years ago)
Author:
Peter Johansson
Message:

removing valid variable - starting to refactor Stats class.

Location:
trunk/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Stats.cc

    r519 r527  
    5151
    5252  Stats::Stats(const std::string& path)
    53     : valid_(true)
    5453  {
    5554    // Make sure latest revision is set properly
     
    115114    last_changed_rev_ = std::max(last_changed_rev_, rhs.last_changed_rev_);
    116115    add_authors(rhs.authors().begin(), rhs.authors().end());
    117     valid_ &= rhs.valid();
    118     // if cache not valid no need to update it
    119     if (valid()) {
    120       base_add(rhs.code_.begin(), rhs.code_.end(), code_);
    121       base_add(rhs.comments_.begin(), rhs.comments_.end(), comments_);
    122       base_add(rhs.other_.begin(), rhs.other_.end(), other_);
    123       base_add(rhs.total_.begin(), rhs.total_.end(), total_);
    124     }
     116    base_add(rhs.code_.begin(), rhs.code_.end(), code_);
     117    base_add(rhs.comments_.begin(), rhs.comments_.end(), comments_);
     118    base_add(rhs.other_.begin(), rhs.other_.end(), other_);
     119    base_add(rhs.total_.begin(), rhs.total_.end(), total_);
    125120  }
    126121
     
    147142                                              std::string user) const
    148143  {
    149     // Peter, we should avoid calling this function prior all
    150     // statistics are calculated. If, for some reason, this is not
    151     // possible call update_stats() first, however, that function is
    152     // not const so some redesign is needed (e.g. making cache mutable
    153     // or making them pointers)
    154     assert(valid() && "trying to access invalid cache of statistics");
    155144    v_map::const_iterator iter(m.find(std::string(user)));
    156145    if (iter==m.end())
     
    189178  u_int Stats::lines(const std::string& user) const
    190179  {
    191     assert(valid()); return get_vector(total_, "all").back();
     180    return get_vector(total_, "all").back();
    192181  }
    193182
     
    195184  void Stats::parse(const std::string& path)
    196185  {
    197     valid_=false;
    198186    // First we let inherited class do parsing
    199187    do_parse(path);
     
    225213  void Stats::plot_summary(const std::string& filename) const
    226214  {
    227     assert(valid());
    228215    plot_init(filename);
    229216    GnuplotFE* gp=GnuplotFE::instance();
     
    308295    VectorPlus<u_int> vp;
    309296    total_["all"] = vp(vp(code_["all"], comments_["all"]), other_["all"]);
    310     valid_=true;
    311297  }
    312298
  • trunk/lib/Stats.h

    r519 r527  
    152152    ///
    153153    void plot_init(const std::string& output) const;
    154     inline bool valid(void) const {return valid_;}
     154
    155155  private:
    156156    virtual bool do_load_cache(std::istream&)=0;
     
    169169    v_map comments_;
    170170    v_map other_;
    171     bool valid_;
     171
    172172    svn_revnum_t revision_; // Should be the latest revision for whole project
    173173    svn_revnum_t last_changed_rev_; // Should be the latest revision for file
Note: See TracChangeset for help on using the changeset viewer.