-/*\r
-* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
-*\r
-* This file is part of CasparCG.\r
-*\r
-* CasparCG is free software: you can redistribute it and/or modify\r
-* it under the terms of the GNU General Public License as published by\r
-* the Free Software Foundation, either version 3 of the License, or\r
-* (at your option) any later version.\r
-*\r
-* CasparCG is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-* GNU General Public License for more details.\r
-\r
-* You should have received a copy of the GNU General Public License\r
-* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
-*\r
-*/\r
-#pragma once\r
-\r
-#include "../memory/safe_ptr.h"\r
-\r
-#include <functional>\r
-#include <string>\r
-#include <vector>\r
-#include <map>\r
-\r
-#include <boost/range/iterator_range.hpp>\r
-#include <boost/circular_buffer.hpp>\r
-\r
-namespace caspar {\r
- \r
-typedef std::function<std::wstring()> printer;\r
- \r
-namespace diagnostics {\r
- \r
-struct color\r
-{\r
- float red;\r
- float green;\r
- float blue;\r
- float alpha;\r
- \r
- color(float r = 0.0f, float g = 0.0f, float b = 0.0f, float a = 1.0f)\r
- : red(r)\r
- , green(g)\r
- , blue(b)\r
- , alpha(a){}\r
-};\r
-\r
-class graph\r
-{\r
- friend safe_ptr<graph> create_graph(const std::string& name);\r
- graph(const std::string& name);\r
-public:\r
- void update_value(const std::string& name, double value);\r
- void update_text(const std::string& value);\r
- void set_value(const std::string& name, double value);\r
- void set_color(const std::string& name, color c);\r
- void add_tag(const std::string& name);\r
- void add_guide(const std::string& name, double value);\r
-private:\r
- struct implementation;\r
- std::shared_ptr<implementation> impl_;\r
-};\r
-\r
-safe_ptr<graph> create_graph(const std::string& name);\r
- \r
-//namespace v2\r
-//{\r
-// \r
-// struct data\r
-// {\r
-// float value;\r
-// };\r
-//\r
-// class line\r
-// {\r
-// public:\r
-// line();\r
-// line(const std::wstring& name);\r
-// std::wstring print() const;\r
-// void update_value(float value);\r
-// void set_value(float value);\r
-// void set_tag(const std::wstring& tag);\r
-//\r
-// boost::circular_buffer<data>& ticks();\r
-// private:\r
-// struct implementation;\r
-// std::shared_ptr<implementation> impl_;\r
-// };\r
-// \r
-// class graph;\r
-//\r
-//\r
-// class graph\r
-// {\r
-// public:\r
-// graph(const std::wstring& name);\r
-// graph(const printer& parent_printer);\r
-//\r
-// void update_value(const std::wstring& name, float value);\r
-// void set_value(const std::wstring& name, float value);\r
-//\r
-// void set_guide(const std::wstring& name, float value);\r
-// void set_color(const std::wstring& name, color c);\r
-//\r
-// color get_color() const;\r
-// std::map<std::wstring, line>& get_lines();\r
-//\r
-// std::wstring print() const;\r
-//\r
-// safe_ptr<graph> clone() const;\r
-// private:\r
-// struct implementation;\r
-// std::shared_ptr<implementation> impl_;\r
-// };\r
-// \r
-// static safe_ptr<graph> create_graph(const std::wstring& name);\r
-// static safe_ptr<graph> create_graph(const printer& parent_printer);\r
-// static std::vector<safe_ptr<graph>> get_all_graphs();\r
-//}\r
-\r
+/*
+* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
+*
+* 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 <http://www.gnu.org/licenses/>.
+*
+* Author: Robert Nagy, ronag89@gmail.com
+*/
+
+#pragma once
+
+#include "../memory.h"
+
+#include <string>
+#include <tuple>
+#include <functional>
+
+#include <boost/noncopyable.hpp>
+
+namespace caspar { namespace diagnostics {
+
+int color(float r, float g, float b, float a = 1.0f);
+std::tuple<float, float, float, float> color(int code);
+
+enum class tag_severity
+{
+ WARNING,
+ INFO
+};
+
+class graph : boost::noncopyable
+{
+ friend void register_graph(const spl::shared_ptr<graph>& 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> impl_;
+};
+
+void register_graph(const spl::shared_ptr<graph>& 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<spl::shared_ptr<graph_sink>()> sink_factory_t;
+void register_sink_factory(sink_factory_t factory);
+
+}
+
}}
\ No newline at end of file