diff options
author | Tim Moore <timoore@redhat.com> | 2009-05-27 10:32:51 +0200 |
---|---|---|
committer | Tim Moore <timoore@redhat.com> | 2009-07-28 10:17:29 +0200 |
commit | 5f4f8b1129659adb2015ce42821faccf8fe6d8d5 (patch) | |
tree | 9fdb07036f2461a01f8efa1f5d07f496191e71bc /grapher/GraphData.hxx | |
parent | 95ddfc079a1d9affdb285f7690f8d5623cd7124a (diff) | |
download | systemtap-steved-5f4f8b1129659adb2015ce42821faccf8fe6d8d5.tar.gz systemtap-steved-5f4f8b1129659adb2015ce42821faccf8fe6d8d5.tar.xz systemtap-steved-5f4f8b1129659adb2015ce42821faccf8fe6d8d5.zip |
Templatize GraphData
* grapher/GraphData.hxx (GraphDataBase): new superclass for
GraphData. Split time data out as a separate vector.
(GraphData): Rewrite as template.
* grapher/GraphWidget.cxx (on_expose_event): Reflect GraphData
templatization. Handle events with string values.
* grapher/GraphWidget.hxx (GraphWidget): Keep pointers to
GraphDataBase objects instead of GraphData.
* grapher/StapParser.cxx (parseData): new member function
(ioCallback): Handle new discreet event
* grapher/StapParser.hxx (StapParser): keep pointers to GraphDataBase
objects instead of GraphData
* testsuite/systemtap.examples/general/grapher.stp: Display actual key
pressed for keyboard event
Diffstat (limited to 'grapher/GraphData.hxx')
-rw-r--r-- | grapher/GraphData.hxx | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/grapher/GraphData.hxx b/grapher/GraphData.hxx index 2c0783c6..9bf3b624 100644 --- a/grapher/GraphData.hxx +++ b/grapher/GraphData.hxx @@ -7,44 +7,38 @@ namespace systemtap { - struct GraphData + struct GraphDataBase { - public: + virtual ~GraphDataBase() {} enum Style { BAR, - DOT + DOT, + EVENT }; - GraphData() : scale(1.0), style(BAR) + GraphDataBase() : scale(1.0), style(BAR) { color[0] = 0.0; color[1] = 1.0; color[2] = 0.0; } - typedef std::pair<double, double> Datum; - typedef std::vector<Datum> List; + typedef std::vector<double> TimeList; // size of grid square at "normal" viewing double scale; double color[3]; Style style; - List data; - struct Compare - { - bool operator() (const Datum& lhs, const Datum& rhs) const - { - return lhs.first < rhs.first; - } - bool operator() (double lhs, const Datum& rhs) const - { - return lhs < rhs.first; - } - bool operator() (const Datum& lhs, double rhs) const - { - return lhs.first < rhs; - } - }; + TimeList times; }; + template<typename T> + class GraphData : public GraphDataBase + { + public: + typedef T data_type; + typedef std::vector<data_type> DataList; + DataList data; + }; struct CSVData { - typedef std::pair<std::string, std::tr1::shared_ptr<GraphData> > Element; + typedef std::pair<std::string, std::tr1::shared_ptr<GraphDataBase> > + Element; std::vector<Element> elements; }; } |