source: trunk/lib/GnuplotFE.h @ 73

Last change on this file since 73 was 73, checked in by Jari Häkkinen, 16 years ago

Divided Gnuplot class into a basic gnuplot communication class
and a front end class specialized for svnstat.
Added option to plot stats against time or revision.
Removed gnuplot usage of temporary files.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.9 KB
Line 
1// $Id: GnuplotFE.h 73 2006-03-04 18:10:07Z jari $
2
3#ifndef _theplu_svnstat_gnuplotfe_
4#define _theplu_svnstat_gnuplotfe_
5
6#include "Gnuplot.h"
7#include <string>
8#include <vector>
9
10
11namespace theplu {
12namespace svnstat {
13
14  ///
15  /// The GnuplotFE class is a front end to the Gnuplot class. This is
16  /// a utility function needed to communicate plotting related
17  /// information between objects.
18  ///
19  /// GnuplotFE provides one single global access point to the
20  /// underlying gnuplot binary and makes sure that there is only one
21  /// point of access to the binary.
22  ///
23  /// @see Design Patterns (the singleton pattern).
24  ///
25  class GnuplotFE : public Gnuplot
26  {
27  public:
28    ///
29    /// The destructor.
30    ///
31    ~GnuplotFE(void) { delete instance_; }
32
33    ///
34    /// @return input format for date.
35    ///
36    // Peter, obsolete ?
37    const std::string& date_input_format(void) { return date_input_format_; }
38
39    ///
40    ///
41    ///
42    void plot(const std::vector<double>& y,const std::string& format="%y-%b-%d");
43
44    ///
45    ///
46    ///
47    void replot(const std::vector<double>& y);
48
49    ///
50    /// @throw Re-throws a GnuplotException from Gnuplot.
51    ///
52    static GnuplotFE* instance(void)
53    { if (!instance_) instance_=new GnuplotFE; return instance_; }
54
55    ///
56    /// sets format of date output.
57    ///
58    inline void set_date_format(const std::string& format)
59    { date_output_format_ = format;}
60
61    ///
62    /// Function setting the dates. \a format must comply with strings
63    /// in date.
64    ///
65    inline void set_dates(const std::vector<std::string>& date,
66                          const std::string& format="%Y-%m-%d")
67    { date_=date; date_input_format_=format; }
68
69  private:
70    ///
71    /// @throw Re-throws a GnuplotException from Gnuplot.
72    ///
73    GnuplotFE(void) {};
74
75    ///
76    /// Copy constructor, not implemented.
77    ///
78    GnuplotFE(const GnuplotFE&);
79
80    std::vector<std::string> date_;
81    std::string date_input_format_;
82    std::string date_output_format_;
83    static GnuplotFE* instance_;
84};
85
86}} // end of namespace svnstat and namespace theplu
87
88#endif
Note: See TracBrowser for help on using the repository browser.