OSSIA
Open Scenario System for Interactive Application
state_print_visitor.hpp
1 #pragma once
2 #include <ossia/detail/config.hpp>
3 #if defined(OSSIA_HAS_FMT)
5 #include <ossia/network/base/node.hpp>
7 #include <ossia/network/base/osc_address.hpp>
8 #include <ossia/network/base/parameter.hpp>
10 #include <ossia/network/value/value.hpp>
11 
12 #include <ostream>
13 #include <string>
14 
15 namespace ossia
16 {
17 struct state_print_visitor
18 {
19  std::ostream& out;
20  std::string padding;
21 
22  void operator()(const state& s)
23  {
24  out << padding << "state {\n";
25  padding.push_back(' ');
26  for(auto& sub : s)
27  ossia::apply_nonnull(*this, sub);
28  padding.pop_back();
29  out << "}\n";
30  }
31 
32  void operator()(const message& m)
33  {
34  out << padding << "message: " << ossia::to_pretty_string(m.dest) << " => "
35  << ossia::value_to_pretty_string(m.message_value);
36 
37  out << "\n";
38  }
39 
40  void operator()(const piecewise_message& m)
41  {
42  out << padding
43  << "piecewise_message: " << ossia::net::address_string_from_node(m.address.get())
44  << " => " << ossia::value_to_pretty_string(m.message_value) << "\n";
45  }
46 
47  template <std::size_t N>
48  void operator()(const piecewise_vec_message<N>& m)
49  {
50  out << padding << "piecewise_vec_message<" << N
51  << ">: " << ossia::net::address_string_from_node(m.address.get()) << " => "
52  << ossia::value_to_pretty_string(m.message_value) << "\n";
53  }
54 
55  void operator()(const ossia::monostate&) { out << "no state\n"; }
56 };
57 }
58 #endif
Definition: git_info.h:7
OSSIA_EXPORT std::string value_to_pretty_string(const ossia::value &val)
getValueAsString Returns a string corresponding to the value
std::string to_pretty_string(const value_with_unit &v)
to_pretty_string Pretty string of unit & value
Definition: dataspace_visitors.cpp:242