1 | // $Id: GnuplotFE.h 123 2006-07-29 22:42:54Z 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 | |
---|
32 | namespace theplu { |
---|
33 | namespace svnstat { |
---|
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 | /// |
---|
63 | /// |
---|
64 | void plot(const std::vector<u_int>& y,const std::string& format="%y-%b"); |
---|
65 | |
---|
66 | /// |
---|
67 | /// |
---|
68 | /// |
---|
69 | void replot(const std::vector<u_int>& y); |
---|
70 | |
---|
71 | /// |
---|
72 | /// @throw Re-throws a GnuplotException from Gnuplot. |
---|
73 | /// |
---|
74 | static GnuplotFE* instance(void) |
---|
75 | { if (!instance_) instance_=new GnuplotFE; return instance_; } |
---|
76 | |
---|
77 | /// |
---|
78 | /// sets format of date output. |
---|
79 | /// |
---|
80 | inline void set_date_format(const std::string& format) |
---|
81 | { date_output_format_ = format;} |
---|
82 | |
---|
83 | /// |
---|
84 | /// Function setting the dates. \a format must comply with strings |
---|
85 | /// in date. |
---|
86 | /// |
---|
87 | inline void set_dates(const std::vector<std::string>& date, |
---|
88 | const std::string& format="%Y-%m-%dT%H:%M:%SZ") |
---|
89 | { date_=date; date_input_format_=format; } |
---|
90 | |
---|
91 | /// |
---|
92 | /// Set the upper value for the y axis, the lower values is always |
---|
93 | /// zero. Call this function with an argument 0 (or without an |
---|
94 | /// argument) to cancel the current setting. Negative argument |
---|
95 | /// values are treated as zero value. |
---|
96 | /// |
---|
97 | /// @return Returns the actual set upper value. A zero value is |
---|
98 | /// returned if the current setting was cancelled. |
---|
99 | /// |
---|
100 | /// @see Gnuplot documentation for yrange |
---|
101 | /// |
---|
102 | double yrange(double ymax=0.0); |
---|
103 | |
---|
104 | private: |
---|
105 | /// |
---|
106 | /// @throw Re-throws a GnuplotException from Gnuplot. |
---|
107 | /// |
---|
108 | GnuplotFE(void) {}; |
---|
109 | |
---|
110 | /// |
---|
111 | /// Copy constructor, not implemented. |
---|
112 | /// |
---|
113 | GnuplotFE(const GnuplotFE&); |
---|
114 | |
---|
115 | std::vector<std::string> date_; |
---|
116 | std::string date_input_format_; |
---|
117 | std::string date_output_format_; |
---|
118 | static GnuplotFE* instance_; |
---|
119 | }; |
---|
120 | |
---|
121 | }} // end of namespace svnstat and namespace theplu |
---|
122 | |
---|
123 | #endif |
---|