source: trunk/lib/GnuplotFE.h @ 97

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

Fixes #30.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.2 KB
Line 
1// $Id: GnuplotFE.h 97 2006-04-01 21:33:44Z jari $
2
3/*
4  Copyright (C) 2006 Jari Häkkinen, Peter Johansson
5
6  This file is part of svnstat, http://lev.thep.lu.se/trac/svnstat
7
8  svnstat 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  svnstat 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_svnstat_gnuplotfe_
25#define _theplu_svnstat_gnuplotfe_
26
27#include "Gnuplot.h"
28#include <string>
29#include <vector>
30
31
32namespace theplu {
33namespace svnstat {
34
35  ///
36  /// The GnuplotFE class is a front end to the Gnuplot class. This is
37  /// a utility function 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  ///
46  class GnuplotFE : public Gnuplot
47  {
48  public:
49    ///
50    /// The destructor.
51    ///
52    ~GnuplotFE(void) { delete instance_; }
53
54    ///
55    /// @return input format for date.
56    ///
57    // Peter, obsolete ?
58    const std::string& date_input_format(void) { return date_input_format_; }
59
60    ///
61    ///
62    ///
63    void plot(const std::vector<u_int>& y,const std::string& format="%y-%b");
64
65    ///
66    ///
67    ///
68    void replot(const std::vector<u_int>& y);
69
70    ///
71    /// @throw Re-throws a GnuplotException from Gnuplot.
72    ///
73    static GnuplotFE* instance(void)
74    { if (!instance_) instance_=new GnuplotFE; return instance_; }
75
76    ///
77    /// sets format of date output.
78    ///
79    inline void set_date_format(const std::string& format)
80    { date_output_format_ = format;}
81
82    ///
83    /// Function setting the dates. \a format must comply with strings
84    /// in date.
85    ///
86    inline void set_dates(const std::vector<std::string>& date,
87                          const std::string& format="%Y-%m-%d")
88    { date_=date; date_input_format_=format; }
89
90    ///
91    /// Set the upper value for the y axis, the lower values is always
92    /// zero. Call this function with an argument 0 (or without an
93    /// argument) to cancel the current setting. Negative argument
94    /// values are treated as zero value.
95    ///
96    /// @return Returns the actual set upper value. A zero value is
97    /// returned if the current setting was cancelled.
98    ///
99    /// @see Gnuplot documentation for yrange
100    ///
101    double yrange(double ymax=0.0);
102
103  private:
104    ///
105    /// @throw Re-throws a GnuplotException from Gnuplot.
106    ///
107    GnuplotFE(void) {};
108
109    ///
110    /// Copy constructor, not implemented.
111    ///
112    GnuplotFE(const GnuplotFE&);
113
114    std::vector<std::string> date_;
115    std::string date_input_format_;
116    std::string date_output_format_;
117    static GnuplotFE* instance_;
118};
119
120}} // end of namespace svnstat and namespace theplu
121
122#endif
Note: See TracBrowser for help on using the repository browser.