OSSIA
Open Scenario System for Interactive Application
dmx_parameter.hpp
1 #pragma once
2 #include <ossia/detail/config.hpp>
3 #if defined(OSSIA_PROTOCOL_ARTNET)
4 #include <ossia/detail/flat_map.hpp>
5 #include <ossia/network/common/device_parameter.hpp>
6 #include <ossia/protocols/artnet/artnet_protocol.hpp>
7 
8 #include <cstdint>
9 
10 namespace ossia::net
11 {
12 
13 template <std::size_t I>
14 struct artnet_visitor;
15 struct dmx_buffer;
16 class OSSIA_EXPORT dmx_parameter : public device_parameter
17 {
18 public:
19  dmx_parameter(
20  net::node_base& node, dmx_buffer& buffer, const unsigned int channel, int min = 0,
21  int max = 255, int8_t bytes = 1);
22  ~dmx_parameter();
23  int8_t m_bytes{};
24 
25  uint32_t channel() const noexcept { return m_channel; }
26 
27  void set_dmx_value(const uint8_t* start, const uint8_t* buffer_end);
28 
29 private:
30  void device_update_value() override;
31 
32  dmx_buffer& m_buffer;
33  const uint32_t m_channel{};
34 
35  template <std::size_t I>
36  friend struct artnet_in_visitor;
37  template <std::size_t I>
38  friend struct artnet_out_visitor;
39 };
40 
41 class OSSIA_EXPORT dmx_enum_parameter : public device_parameter
42 {
43 public:
44  dmx_enum_parameter(
45  net::node_base& node, dmx_parameter& p,
46  std::vector<std::pair<std::string, uint8_t>> values);
47  ~dmx_enum_parameter();
48 
49 private:
50  void device_update_value() override;
51 
52  dmx_parameter& m_param;
53 
54  ossia::flat_map<std::string, uint8_t> m_map;
55 
56  friend struct artnet_enum_visitor;
57 };
58 
59 /*
60 struct artnet_range_element {
61  std::string name;
62  int min{0};
63  int max{512};
64 };
65 
66 class artnet_range_parameter : public device_parameter
67 {
68  using dmx_buffer = artnet_protocol::dmx_buffer;
69 
70 public:
71  artnet_range_parameter(
72  net::node_base& node, dmx_buffer& buffer, unsigned int channel, int min,
73 int max); ~artnet_range_parameter();
74 
75 private:
76  void device_update_value() override;
77 
78  dmx_buffer& m_buffer;
79  const unsigned int m_channel{};
80 
81  friend struct artnet_range_visitor;
82 };
83 */
84 
85 }
86 #endif
constexpr OSSIA_INLINE auto min(const T a, const U b) noexcept -> typename std::conditional<(sizeof(T) > sizeof(U)), T, U >::type
min function tailored for values
Definition: math.hpp:125
constexpr OSSIA_INLINE auto max(const T a, const U b) noexcept -> typename std::conditional<(sizeof(T) > sizeof(U)), T, U >::type
max function tailored for values
Definition: math.hpp:96