source: trunk/lib/GnuplotFE.h @ 74

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

Improved web presentation. Y axises normalized, ticket ticket:15 resolved.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.4 KB
Line 
1// $Id: GnuplotFE.h 74 2006-03-07 15:46:59Z 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<u_int>& y,const std::string& format="%y-%b-%d");
43
44    ///
45    ///
46    ///
47    void replot(const std::vector<u_int>& 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    ///
70    /// Set the upper value for the y axis, the lower values is always
71    /// zero. Call this function with an argument 0 (or without an
72    /// argument) to cancel the current setting. Negative argument
73    /// values are treated as zero value.
74    ///
75    /// @return Returns the actual set upper value. A zero value is
76    /// returned if the current setting was cancelled.
77    ///
78    /// @see Gnuplot documentation for yrange
79    ///
80    double yrange(double ymax=0.0);
81
82  private:
83    ///
84    /// @throw Re-throws a GnuplotException from Gnuplot.
85    ///
86    GnuplotFE(void) {};
87
88    ///
89    /// Copy constructor, not implemented.
90    ///
91    GnuplotFE(const GnuplotFE&);
92
93    std::vector<std::string> date_;
94    std::string date_input_format_;
95    std::string date_output_format_;
96    static GnuplotFE* instance_;
97};
98
99}} // end of namespace svnstat and namespace theplu
100
101#endif
Note: See TracBrowser for help on using the repository browser.