summaryrefslogtreecommitdiffstats
path: root/grapher/GraphData.hxx
blob: 0e26fb4d8c73ca61e208a0189a69d70426e71af4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef SYSTEMTAP_GRAPHDATA_HXX
#define SYSTEMTAP_GRAPHDATA_HXX 1

#include <string>
#include <utility>
#include <vector>
#include <tr1/memory>

#include <boost/circular_buffer.hpp>

namespace systemtap
{
  struct GraphDataBase
  {
    virtual ~GraphDataBase() {}
    enum Style
      { BAR,
        DOT,
        EVENT
      };
    typedef boost::circular_buffer<double> TimeList;
    GraphDataBase(TimeList::capacity_type cap = 50000)
      : scale(1.0), style(BAR), times(cap)
    {
      color[0] = 0.0;  color[1] = 1.0;  color[2] = 0.0;
    }
    // size of grid square at "normal" viewing
    double scale;
    double color[3];
    Style style;
    std::string title;
    std::string xAxisText;
    std::string yAxisText;
    TimeList times;
  };

  template<typename T>
  class GraphData : public GraphDataBase
  {
  public:
    typedef T data_type;
    typedef boost::circular_buffer<data_type> DataList;
    GraphData(typename DataList::capacity_type cap = 50000)
      : GraphDataBase(cap), data(cap)
    {
    }
    DataList data;
  };
  struct CSVData
  {
    typedef std::pair<std::string, std::tr1::shared_ptr<GraphDataBase> >
    Element;
    std::vector<Element> elements;
  };
}
#endif