struct graph::implementation : public drawable\r
{\r
std::map<std::string, diagnostics::line> lines_;\r
- const printer parent_printer_;\r
std::string name_;\r
+ std::string text_;\r
\r
int counter_;\r
\r
implementation(const std::string& name) \r
: name_(name)\r
+ , text_(name)\r
, counter_(0){}\r
-\r
- implementation(const printer& parent_printer) \r
- : parent_printer_(parent_printer)\r
- , name_(parent_printer_ ? narrow(parent_printer_()) : "")\r
- , counter_(0){}\r
-\r
+ \r
void update(const std::string& name, double value)\r
{\r
lines_[name].update(value);\r
}\r
\r
+ void update_text(const std::string& value)\r
+ {\r
+ text_ = value;\r
+ }\r
+\r
void set(const std::string& name, double value)\r
{\r
lines_[name].set(value);\r
private:\r
void render(sf::RenderTarget& target)\r
{\r
- if(counter_++ > 25) // Don't update name too often since print can be implemented with locks.\r
- {\r
- counter_ = 0;\r
- if(parent_printer_)\r
- name_ = narrow(parent_printer_());\r
- }\r
const size_t text_size = 15;\r
const size_t text_margin = 2;\r
const size_t text_offset = (text_size+text_margin*2)*2;\r
\r
- sf::String text(name_.c_str(), sf::Font::GetDefaultFont(), text_size);\r
+ sf::String text(text_.c_str(), sf::Font::GetDefaultFont(), text_size);\r
text.SetStyle(sf::String::Italic);\r
text.Move(text_margin, text_margin);\r
\r
context::register_drawable(impl_);\r
}\r
\r
-graph::graph(const printer& parent_printer) : impl_(env::properties().get("configuration.diagnostics.graphs", true) ? new implementation(parent_printer) : nullptr)\r
+void graph::update_value(const std::string& name, double value)\r
{\r
if(impl_)\r
- context::register_drawable(impl_);\r
+ { \r
+ auto p = impl_;\r
+ context::begin_invoke([=]\r
+ { \r
+ p->update(name, value);\r
+ });\r
+ }\r
}\r
\r
-void graph::update_value(const std::string& name, double value)\r
+void graph::update_text(const std::string& value)\r
{\r
if(impl_)\r
- { \r
+ { \r
auto p = impl_;\r
context::begin_invoke([=]\r
{ \r
- p->update(name, value);\r
+ p->update_text(value);\r
});\r
}\r
}\r
+\r
void graph::set_value(const std::string& name, double value)\r
{\r
if(impl_)\r
{\r
return safe_ptr<graph>(new graph(name));\r
}\r
-safe_ptr<graph> create_graph(const printer& parent_printer)\r
-{\r
- return safe_ptr<graph>(new graph(parent_printer));\r
-}\r
-\r
\r
//namespace v2\r
//{ \r
class graph\r
{\r
friend safe_ptr<graph> create_graph(const std::string& name);\r
- friend safe_ptr<graph> create_graph(const printer& parent_printer);\r
graph(const std::string& name);\r
- graph(const printer& parent_printer);\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
};\r
\r
safe_ptr<graph> create_graph(const std::string& name);\r
-safe_ptr<graph> create_graph(const printer& parent_printer);\r
\r
//namespace v2\r
//{\r
\r
safe_ptr() : impl_(std::make_shared<T>()){} \r
\r
- safe_ptr(const safe_ptr<T>& other) : impl_(other.impl_){} // noexcept\r
- safe_ptr(safe_ptr<T>&& other) : impl_(std::move(other.impl_)){}\r
+ safe_ptr(const safe_ptr& other) : impl_(other.impl_){} // noexcept\r
+ safe_ptr(safe_ptr&& other) : impl_(std::move(other.impl_)){}\r
\r
template<typename U>\r
safe_ptr(const safe_ptr<U>& other, typename std::enable_if<std::is_convertible<U*, T*>::value, void*>::type = 0) : impl_(other.impl_){} // noexcept\r
}\r
\r
template<typename U>\r
- typename std::enable_if<std::is_convertible<U*, T*>::value, safe_ptr<T>&>::type\r
+ typename std::enable_if<std::is_convertible<typename std::add_pointer<U>::type, T*>::value, safe_ptr&>::type\r
operator=(const safe_ptr<U>& other)\r
{\r
- safe_ptr<T> temp(other);\r
- temp.swap(*this);\r
+ safe_ptr(other).swap(*this);\r
+ return *this;\r
+ }\r
+\r
+ template<typename U>\r
+ typename std::enable_if<std::is_convertible<typename std::add_pointer<U>::type, T*>::value, safe_ptr&>::type\r
+ operator=(safe_ptr<U>&& other)\r
+ {\r
+ safe_ptr(std::move(other)).swap(*this);\r
return *this;\r
}\r
\r
template <typename U>\r
- typename std::enable_if<std::is_convertible<typename std::add_pointer<U>::type, T*>::value, safe_ptr<T>&>::type\r
+ typename std::enable_if<std::is_convertible<typename std::add_pointer<U>::type, T*>::value, safe_ptr&>::type\r
operator=(U&& impl)\r
{\r
- safe_ptr<T> temp(std::forward<T>(impl));\r
+ safe_ptr temp(std::forward<T>(impl));\r
temp.swap(*this);\r
return *this;\r
}\r
operator const std::shared_ptr<T>&() const { return impl_;} // noexcept\r
\r
template<class U>\r
- bool owner_before(const safe_ptr<T>& ptr){ return impl_.owner_before(ptr.impl_); } // noexcept\r
+ bool owner_before(const safe_ptr& ptr){ return impl_.owner_before(ptr.impl_); } // noexcept\r
\r
template<class U>\r
bool owner_before(const std::shared_ptr<U>& ptr){ return impl_.owner_before(ptr); } // noexcept\r
\r
\r
/* File created by MIDL compiler version 7.00.0555 */\r
-/* at Wed Sep 21 22:02:53 2011\r
+/* at Wed Sep 21 23:31:49 2011\r
*/\r
/* Compiler settings for interop\DeckLinkAPI.idl:\r
Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 7.00.0555 \r
\r
\r
/* File created by MIDL compiler version 7.00.0555 */\r
-/* at Wed Sep 21 22:02:53 2011\r
+/* at Wed Sep 21 23:31:49 2011\r
*/\r
/* Compiler settings for interop\DeckLinkAPI.idl:\r
Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 7.00.0555 \r
{\r
frame_buffer_.set_capacity(2);\r
\r
- graph_ = diagnostics::create_graph(boost::bind(&decklink_producer::print, this));\r
+ graph_ = diagnostics::create_graph(narrow(print()));\r
graph_->add_guide("tick-time", 0.5);\r
graph_->set_color("tick-time", diagnostics::color(0.0f, 0.6f, 0.9f)); \r
graph_->set_color("late-frame", diagnostics::color(0.6f, 0.3f, 0.3f));\r
public:\r
explicit ffmpeg_producer(const safe_ptr<core::frame_factory>& frame_factory, const std::wstring& filename, const std::wstring& filter, bool loop, int start, size_t length) \r
: filename_(filename)\r
- , graph_(diagnostics::create_graph([this]{return print();}))\r
+ , graph_(diagnostics::create_graph(""))\r
, frame_factory_(frame_factory) \r
, format_desc_(frame_factory->get_video_format_desc())\r
, input_(graph_, filename_, loop, start, length)\r
else \r
graph_->add_tag("underflow"); \r
}\r
+\r
+ graph_->update_text(narrow(print()));\r
\r
return frame;\r
}\r
\r
fps_ = 0;\r
\r
- graph_ = diagnostics::create_graph([this]{return print();});\r
+ graph_ = diagnostics::create_graph(narrow(print()));\r
graph_->set_color("output-buffer-count", diagnostics::color(1.0f, 1.0f, 0.0f)); \r
graph_->set_color("underflow", diagnostics::color(0.6f, 0.3f, 0.9f)); \r
\r
}\r
\r
graph_->set_value("output-buffer-count", static_cast<float>(frame_buffer_.size())/static_cast<float>(frame_buffer_.capacity())); \r
- fps_.fetch_and_store(static_cast<int>(context_->fps()*100.0));\r
+ fps_.fetch_and_store(static_cast<int>(context_->fps()*100.0)); \r
+ graph_->update_text(narrow(print()));\r
\r
render(renderer);\r
}\r
<device>1</device>\r
<embedded-audio>true</embedded-audio>\r
</decklink>\r
- <screen></screen>\r
</consumers>\r
</channel>\r
</channels>\r