// systemtap grapher // Copyright (C) 2009 Red Hat Inc. // // This file is part of systemtap, and is free software. You can // redistribute it and/or modify it under the terms of the GNU General // Public License (GPL); either version 2, or (at your option) any // later version. #ifndef SYSTEMTAP_GRAPHDATA_HXX #define SYSTEMTAP_GRAPHDATA_HXX 1 #include #include #include #include #include #include #include #include #include "GraphStyle.hxx" namespace systemtap { struct GraphDataBase; typedef std::vector > GraphDataList; struct GraphDataBase { virtual ~GraphDataBase() {} typedef boost::circular_buffer TimeList; GraphDataBase(TimeList::capacity_type cap = 50000) : scale(1.0), style(&GraphStyleBar::instance), times(cap) { color[0] = 0.0; color[1] = 1.0; color[2] = 0.0; } virtual std::string elementAsString(size_t element) = 0; // size of grid square at "normal" viewing std::string name; double scale; double color[3]; GraphStyle* style; std::string title; std::string xAxisText; std::string yAxisText; TimeList times; static GraphDataList graphData; // signal stuff for telling everyone about changes to the data set list static sigc::signal graphDataChanged; }; template class GraphData : public GraphDataBase { public: typedef T data_type; typedef boost::circular_buffer DataList; GraphData(typename DataList::capacity_type cap = 50000) : GraphDataBase(cap), data(cap) { } std::string elementAsString(size_t element) { std::ostringstream stream; stream << data[element]; return stream.str(); } DataList data; }; struct CSVData { typedef std::pair > Element; std::vector elements; }; inline GraphDataList& getGraphData() { return GraphDataBase::graphData; } inline sigc::signal& graphDataSignal() { return GraphDataBase::graphDataChanged; } } #endif