source: tags/0.6.8/lib/GnuplotFE.h @ 848

Last change on this file since 848 was 731, checked in by Peter Johansson, 13 years ago

update copyright statements

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