source: trunk/lib/GnuplotFE.h @ 149

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

Changed svnstat to svndigest.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.3 KB
Line 
1// $Id: GnuplotFE.h 149 2006-08-12 09:11:46Z jari $
2
3/*
4  Copyright (C) 2006 Jari Häkkinen, Peter Johansson
5
6  This file is part of svndigest, http://lev.thep.lu.se/trac/svndigest
7
8  svndigest is free software; you can redistribute it and/or modify it
9  under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.
12
13  svndigest is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21  02111-1307, USA.
22*/
23
24#ifndef _theplu_svndigest_gnuplotfe_
25#define _theplu_svndigest_gnuplotfe_
26
27#include "Gnuplot.h"
28#include <string>
29#include <vector>
30
31
32namespace theplu {
33namespace svndigest {
34
35  ///
36  /// The GnuplotFE class is a front end to the Gnuplot class. This is
37  /// a utility class needed to communicate plotting related
38  /// information between objects.
39  ///
40  /// GnuplotFE provides one single global access point to the
41  /// underlying gnuplot binary and makes sure that there is only one
42  /// point of access to the binary.
43  ///
44  /// @see Design Patterns (the singleton pattern).
45  /// @see Gnuplot
46  ///
47  class GnuplotFE : public Gnuplot
48  {
49  public:
50    ///
51    /// The destructor.
52    ///
53    ~GnuplotFE(void) { delete instance_; }
54
55    ///
56    /// @return input format for date.
57    ///
58    // Peter, obsolete ?
59    const std::string& date_input_format(void) { return date_input_format_; }
60
61    ///
62    /// Plot the data \a y. If a date vector is set with set_dates
63    /// function before calling this function, the date vector will be
64    /// used as x values using \a format as date format
65    /// description. If no date vector is set then the \a y data will
66    /// be plot as a function of subversion revision.
67    ///
68    /// @see Gnuplot documentation for date formats.
69    ///
70    /// @note \a y may change in this call: In some cases the date and
71    /// \a y data vectors may have different length. This is an effect
72    /// from subversions treatment of revisions, i.e., subversion
73    /// controlled items may have different revisions but still up to
74    /// date (at the items last changed revision). The date vector
75    /// typically contains all revisions of the repository and thus a
76    /// clash of different sized vectors may occur in gnuplot. This
77    /// situation is resolved by adding elements to \a y such that the
78    /// vector sizes match. The date vector is never expected to be
79    /// shorter than \a y vector.
80    ///
81    void plot(std::vector<u_int>& y,const std::string& format="%y-%b");
82
83    ///
84    /// Plot the data \a y as a function of \a x using the Gnuplot
85    /// 'replot' command, see plot documentation for information on x
86    /// axis data and possible modifications of \a y.
87    ///
88    void replot(std::vector<u_int>& y);
89
90    ///
91    /// @throw Re-throws a GnuplotException from Gnuplot.
92    ///
93    static GnuplotFE* instance(void)
94    { if (!instance_) instance_=new GnuplotFE; return instance_; }
95
96    ///
97    /// sets format of date output.
98    ///
99    inline void set_date_format(const std::string& format)
100    { date_output_format_ = format;}
101
102    ///
103    /// Function setting the dates. \a format must comply with strings
104    /// in date.
105    ///
106    inline void set_dates(const std::vector<std::string>& date,
107                          const std::string& format="%Y-%m-%dT%H:%M:%SZ")
108    { date_=date; date_input_format_=format; }
109
110    ///
111    /// Set the upper value for the y axis, the lower values is always
112    /// zero. Call this function with an argument 0 (or without an
113    /// argument) to cancel the current setting. Negative argument
114    /// values are treated as zero value.
115    ///
116    /// @return Returns the actual set upper value. A zero value is
117    /// returned if the current setting was cancelled.
118    ///
119    /// @see Gnuplot documentation for yrange
120    ///
121    double yrange(double ymax=0.0);
122
123  private:
124    ///
125    /// @throw Re-throws a GnuplotException from Gnuplot.
126    ///
127    GnuplotFE(void) {};
128
129    ///
130    /// Copy constructor, not implemented.
131    ///
132    GnuplotFE(const GnuplotFE&);
133
134    std::vector<std::string> date_;
135    std::string date_input_format_;
136    std::string date_output_format_;
137    static GnuplotFE* instance_;
138};
139
140}} // end of namespace svndigest and namespace theplu
141
142#endif
Note: See TracBrowser for help on using the repository browser.