Changeset 39


Ignore:
Timestamp:
Jan 13, 2006, 4:02:31 PM (16 years ago)
Author:
Jari Häkkinen
Message:

Gnuplot working.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/Parameter.cc

    r37 r39  
    1616      bool ok=false;
    1717      std::string myargv(argv[i]);
    18       if (myargv=="-d" || myargv=="-dir"){
     18      if (myargv=="-d" || myargv=="--directory"){
    1919        if (++i<argc){
    2020          outdir_= std::string(argv[i]);
     
    2222        }
    2323      }
    24       else if (myargv=="-f" || myargv=="-force"){
     24      else if (myargv=="-f" || myargv=="--force"){
    2525          force_=true;
    2626          ok=true;
    2727      }
    28       else if (myargv=="-h" || myargv=="-help"){
     28      else if (myargv=="-h" || myargv=="--help"){
    2929        help();
    3030        exit(0);      // always exit after printing help
    3131      }
    32       else if (myargv=="-v" || myargv=="-verbose"){
     32      else if (myargv=="-v" || myargv=="--verbose"){
    3333          verbose_=true;
    3434          ok=true;
    3535      }
    36       else if (myargv=="-version"){
     36      else if (myargv=="--version"){
    3737          version();
    3838          exit(0);
     
    4444      if (!ok){
    4545        std::cerr << "svnstat: invalid option: " << myargv << "\n"
    46                   << "Type 'svnstat -help' for usage." << std::endl;
     46                  << "Type 'svnstat --help' for usage." << std::endl;
    4747        exit(-1);
    4848      }
     
    5353
    5454
    55 
    5655  void Parameter::analyse(void)
    5756  {
    5857  }
    5958
    60  
    6159
    6260  void Parameter::help(void)
     
    7371              << "\n"
    7472              << "Valid options:\n"
    75               << "  -d(ir) arg  : output directory [svnstat]\n"
    76               << "  -f(orce)     : overwrite existing files\n"
    77               << "  -h(elp)      : display this help and exit\n"
    78               << "  -v(erbose)  : explain what is being done\n"
    79               << "  -version     : print version information and exit\n"
     73              << "  -d [--dir] arg : output directory [svnstat]\n"
     74              << "  -f [--force]   : overwrite existing files\n"
     75              << "  -h [--help]    : display this help and exit\n"
     76              << "  -v [--verbose] : explain what is being done\n"
     77              << "  --version      : print version information and exit\n"
    8078              << std::endl;
    8179  }
  • trunk/lib/Gnuplot.cc

    r36 r39  
    1414
    1515  Gnuplot::Gnuplot(void)
    16     : linestyle_("lines"), pipe_(NULL)
     16    : linestyle_("steps"), pipe_(NULL)
    1717  {
    1818    acquire_program_path("gnuplot");
  • trunk/lib/Gnuplot.h

    r36 r39  
    1818  ///
    1919  struct GnuplotException : public std::runtime_error
    20   { inline GnuplotException(const std::string &msg) : runtime_error(msg) {} };
     20  { inline GnuplotException(const std::string& msg) : runtime_error(msg) {} };
    2121
    2222  ///
     
    6161    /// @note The \a style is not checked to be valid.
    6262    ///
    63     inline void linestyle(std::string style) { linestyle_=style; }
     63    inline void linestyle(const std::string& style) { linestyle_=style; }
    6464
    6565    ///
     
    6868    /// called again.
    6969    ///
    70     inline void linetitle(std::string title) { linetitle_=title; }
     70    inline void linetitle(const std::string& title) { linetitle_=title; }
    7171
    7272    ///
  • trunk/lib/Stats.cc

    r38 r39  
    1010#include <map>
    1111#include <numeric>
     12#include <sstream>
    1213#include <string>
    1314#include <utility>
     
    7273    std::string cmd=std::string("set term png; set output '")+name+".png'";
    7374    gnuplot_pipe_.command(cmd);
    74     gnuplot_pipe_.plot(accumulated());
    75     for (MapConstIter_ i= map_.begin(); i != map_.end(); i++)
    76       gnuplot_pipe_.replot(accumulated(i->first));
     75    gnuplot_pipe_.command("set key left Left reverse");
     76    std::vector<double> x=accumulated();
     77    std::stringstream sa;
     78    sa << x.back() << " total";
     79    gnuplot_pipe_.linetitle(sa.str());
     80    gnuplot_pipe_.plot(x);
     81    for (MapConstIter_ i= map_.begin(); i != map_.end(); i++) {
     82      x=accumulated(i->first);
     83      std::stringstream s;
     84      s << x.back() << " " << i->first;
     85      gnuplot_pipe_.linetitle(s.str());
     86      gnuplot_pipe_.replot(x);
     87    }
    7788
    7889    // Jari, must rewrite output once since the replots above are not
     
    8697  void Stats::print(std::ostream& os) const
    8798  {
    88     std::vector<std::pair<std::string, std::vector<u_int> > > accum;
    89     for (MapConstIter_ i= map_.begin(); i != map_.end(); i++){
    90       std::pair<std::string, std::vector<u_int> > element(*i);
    91       std::partial_sum(element.second.begin(),element.second.end(),
    92                        element.second.begin());
    93       accum.push_back(element);
    94     }
    95     sort(accum.begin(),accum.end(), CodingMore());
    96     os << "<table>\n";
    97     for (size_t i = 0; i<accum.size(); i++){
    98       os << "<tr><td>\n" << accum[i].first << "</td><td>"
    99          << accum[i].second.back() << "</td></tr>";
    100     }
    101     os << "</table>\n";
    102 
    10399    os << "<p><img src='" << plot() << "' alt='[svnstat plot]' border=0></p>\n";
    104100  }
  • trunk/lib/utility.h

    r23 r39  
    5858
    5959  ///
     60  /// Jari, is this obsolete? And thus erasable?
     61  ///
    6062  struct CodingMore :
    6163    public std::binary_function<std::pair<std::string,std::vector<u_int> >,
Note: See TracChangeset for help on using the changeset viewer.