X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=common%2Fdiagnostics%2Fgraph.h;h=0b8888013609fd45a9ae806084125d14de46c309;hb=a9baf9ba1e7e4b94b5e08385328441de6607ad23;hp=0d9ef3d6226c954a11b522a8caeec23a2da5e816;hpb=11e9ee9363a33cee4f3433c83b1f5fd76b95b57e;p=casparcg diff --git a/common/diagnostics/graph.h b/common/diagnostics/graph.h index 0d9ef3d62..0b8888013 100644 --- a/common/diagnostics/graph.h +++ b/common/diagnostics/graph.h @@ -1,125 +1,79 @@ -/* -* copyright (c) 2010 Sveriges Television AB -* -* This file is part of CasparCG. -* -* CasparCG is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* CasparCG is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with CasparCG. If not, see . -* -*/ -#pragma once - -#include "../memory/safe_ptr.h" - -#include -#include -#include -#include - -#include -#include - -namespace caspar { - -typedef std::function printer; - -namespace diagnostics { - -struct color -{ - float red; - float green; - float blue; - float alpha; - - color(float r = 0.0f, float g = 0.0f, float b = 0.0f, float a = 1.0f) - : red(r) - , green(g) - , blue(b) - , alpha(a){} -}; - -class graph -{ - friend safe_ptr create_graph(const std::string& name); - graph(const std::string& name); -public: - void update_value(const std::string& name, double value); - void update_text(const std::string& value); - void set_value(const std::string& name, double value); - void set_color(const std::string& name, color c); - void add_tag(const std::string& name); - void add_guide(const std::string& name, double value); -private: - struct implementation; - std::shared_ptr impl_; -}; - -safe_ptr create_graph(const std::string& name); - -//namespace v2 -//{ -// -// struct data -// { -// float value; -// }; -// -// class line -// { -// public: -// line(); -// line(const std::wstring& name); -// std::wstring print() const; -// void update_value(float value); -// void set_value(float value); -// void set_tag(const std::wstring& tag); -// -// boost::circular_buffer& ticks(); -// private: -// struct implementation; -// std::shared_ptr impl_; -// }; -// -// class graph; -// -// -// class graph -// { -// public: -// graph(const std::wstring& name); -// graph(const printer& parent_printer); -// -// void update_value(const std::wstring& name, float value); -// void set_value(const std::wstring& name, float value); -// -// void set_guide(const std::wstring& name, float value); -// void set_color(const std::wstring& name, color c); -// -// color get_color() const; -// std::map& get_lines(); -// -// std::wstring print() const; -// -// safe_ptr clone() const; -// private: -// struct implementation; -// std::shared_ptr impl_; -// }; -// -// static safe_ptr create_graph(const std::wstring& name); -// static safe_ptr create_graph(const printer& parent_printer); -// static std::vector> get_all_graphs(); -//} - +/* +* Copyright (c) 2011 Sveriges Television AB +* +* This file is part of CasparCG (www.casparcg.com). +* +* CasparCG is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* CasparCG is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with CasparCG. If not, see . +* +* Author: Robert Nagy, ronag89@gmail.com +*/ + +#pragma once + +#include "../memory.h" + +#include +#include +#include + +#include + +namespace caspar { namespace diagnostics { + +int color(float r, float g, float b, float a = 1.0f); +std::tuple color(int code); + +enum class tag_severity +{ + WARNING, + INFO +}; + +class graph : boost::noncopyable +{ + friend void register_graph(const spl::shared_ptr& graph); +public: + graph(); + void set_text(const std::wstring& value); + void set_value(const std::string& name, double value); + void set_color(const std::string& name, int color); + void set_tag(tag_severity severity, const std::string& name); + void auto_reset(); +private: + struct impl; + std::shared_ptr impl_; +}; + +void register_graph(const spl::shared_ptr& graph); + +namespace spi { + +class graph_sink : boost::noncopyable +{ +public: + virtual ~graph_sink() { } + virtual void activate() = 0; + virtual void set_text(const std::wstring& value) = 0; + virtual void set_value(const std::string& name, double value) = 0; + virtual void set_color(const std::string& name, int color) = 0; + virtual void set_tag(tag_severity severity, const std::string& name) = 0; + virtual void auto_reset() = 0; +}; + +typedef std::function()> sink_factory_t; +void register_sink_factory(sink_factory_t factory); + +} + }} \ No newline at end of file