OSSIA
Open Scenario System for Interactive Application
Loading...
Searching...
No Matches
minuit.hpp
1#pragma once
2#include <ossia/detail/mutex.hpp>
4#include <ossia/network/base/listening.hpp>
5#include <ossia/network/base/protocol.hpp>
6#include <ossia/network/minuit/detail/minuit_name_table.hpp>
7#include <ossia/network/value/value.hpp>
8#include <ossia/network/zeroconf/zeroconf.hpp>
9
10#include <atomic>
11#include <future>
12#include <string>
13
14namespace oscpack
15{
16class ReceivedMessage;
17class IpEndpointName;
18}
19namespace osc
20{
21template <typename T>
22class sender;
23class receiver;
24}
25
26namespace ossia::net
27{
28struct osc_1_0_outbound_stream_visitor;
29class generic_device;
30class OSSIA_EXPORT minuit_protocol final : public ossia::net::protocol_base
31{
32private:
33 using lock_type = lock_t;
34
35public:
36 minuit_protocol(
37 const std::string& local_name, const std::string& remote_ip, uint16_t remote_port,
38 uint16_t local_port);
39
40 minuit_protocol(const minuit_protocol&) = delete;
41 minuit_protocol(minuit_protocol&&) = delete;
42 minuit_protocol& operator=(const minuit_protocol&) = delete;
43 minuit_protocol& operator=(minuit_protocol&&) = delete;
44
45 ~minuit_protocol();
46
47 void set_device(ossia::net::device_base& dev) override;
48
49 const std::string& get_ip() const;
50 minuit_protocol& set_ip(std::string);
51
52 uint16_t get_remote_port() const;
53 minuit_protocol& set_remote_port(uint16_t);
54
55 uint16_t get_local_port() const;
56 minuit_protocol& set_local_port(uint16_t);
57
58 bool update(ossia::net::node_base& node_base) override;
59
60 bool pull(ossia::net::parameter_base& parameter_base) override;
61 bool push_raw(const ossia::net::full_parameter_data& parameter_base) override;
62 std::future<void> pull_async(parameter_base&) override;
63 void request(ossia::net::parameter_base& parameter_base) override;
64
65 bool
66 push(const ossia::net::parameter_base& parameter_base, const ossia::value& v) override;
67
68 bool observe(ossia::net::parameter_base& parameter_base, bool enable) override;
69 bool observe_quietly(ossia::net::parameter_base& parameter_base, bool enable) override;
70
71 void namespace_refresh(std::string_view req, const std::string& addr);
72 void namespace_refreshed(std::string_view addr);
73
74 void
75 get_refresh(std::string_view req, const std::string& addr, std::promise<void>&& p);
76 void get_refreshed(std::string_view req);
77
79 ossia::minuit::name_table name_table;
80
81private:
82 void on_received_message(
83 const oscpack::ReceivedMessage& m, const oscpack::IpEndpointName& ip);
84
85 void update_zeroconf();
86
87 std::string m_localName;
88 std::string m_ip;
89 uint16_t m_remotePort{};
90 uint16_t m_localPort{};
92
93 listened_parameters m_listening;
94
95 std::promise<void> m_namespaceFinishedPromise;
96 ossia::net::device_base* m_device{};
97
98 mutex_t m_nsRequestMutex;
99 ossia::hash_set<std::string> m_nsRequests;
100
101 mutex_t m_getRequestMutex;
102 ossia::string_map<std::promise<void>> m_getRequests;
103
104 std::unique_ptr<osc::sender<osc_1_0_outbound_stream_visitor>> m_sender;
105 std::unique_ptr<osc::receiver> m_receiver;
106
107 zeroconf_server m_zcServer;
108
109 message_origin_identifier m_id;
110
111 std::atomic<long long> m_lastSentMessage;
112 std::atomic<long long> m_lastRecvMessage;
113};
114}
The sender class.
Definition sender.hpp:27
Root of a device tree.
Definition ossia/network/base/device.hpp:58
The node_base class.
Definition node.hpp:48
The parameter_base class.
Definition ossia/network/base/parameter.hpp:48
The protocol_base class.
Definition protocol.hpp:40
The value class.
Definition value.hpp:173
Full information about a parameter.
Definition parameter_data.hpp:61