OSSIA
Open Scenario System for Interactive Application
mapping.hpp
1 #pragma once
2 #include <ossia/detail/config.hpp>
3 
4 #include <ossia/dataflow/graph_node.hpp>
5 #include <ossia/dataflow/port.hpp>
6 #include <ossia/detail/optional.hpp>
8 #include <ossia/editor/mapper/detail/mapper_visitor.hpp>
13 namespace ossia::nodes
14 {
23 class mapping final : public ossia::nonowning_graph_node
24 {
25 public:
26  mapping()
27  {
28  m_inlets.push_back(&value_in);
29  m_outlets.push_back(&value_out);
30  }
31 
32  [[nodiscard]] std::string label() const noexcept override { return "mapping"; }
33 
34  ~mapping() override = default;
35 
36  void set_behavior(const ossia::behavior& b) { m_drive = b; }
37 
38 private:
39  void run(const ossia::token_request& t, ossia::exec_state_facade e) noexcept override
40  {
41  if(!m_drive)
42  return;
43 
44  const ossia::value_port& ip = *value_in;
45  ossia::value_port& op = *value_out;
46 
47  // TODO use correct unit / whatever ?
48  for(auto& tv : ip.get_data())
49  {
50  if(tv.value.valid())
51  try
52  {
53  auto v = ossia::apply(
54  ossia::detail::mapper_compute_visitor{}, tv.value, m_drive.v);
55 
56  op.write_value(std::move(v), tv.timestamp);
57  }
58  catch(...)
59  {
60  }
61  }
62  }
63 
64  ossia::behavior m_drive;
65  ossia::value_inlet value_in;
66  ossia::value_outlet value_out;
67 };
68 }
The ossia::nodes::mapping class.
Definition: mapping.hpp:24