OSSIA
Open Scenario System for Interactive Application
Loading...
Searching...
No Matches
ossia/network/base/parameter.hpp
1#pragma once
2#include <ossia/detail/config.hpp>
3
6#include <ossia/detail/optional.hpp>
7#include <ossia/detail/std_fwd.hpp>
8#include <ossia/network/base/value_callback.hpp>
9#include <ossia/network/common/parameter_properties.hpp>
10#include <ossia/network/dataspace/dataspace_fwd.hpp>
11#include <ossia/network/domain/domain_fwd.hpp>
13
14#include <nano_signal_slot.hpp>
15
16#include <ciso646>
17#include <functional>
18#include <memory>
19#include <vector>
20OSSIA_STD_BEGIN_NAMESPACE
21template <typename T>
22class future;
23OSSIA_STD_END_NAMESPACE
24
25/*
26extern template class ossia::callback_container<ossia::value_callback>;
27extern template class std::future<void>;
28*/
29namespace ossia
30{
31class value;
32namespace net
33{
34class node_base;
35class protocol_base;
36struct full_parameter_data;
37
47class OSSIA_EXPORT parameter_base : public callback_container<value_callback>
48{
49public:
51 : m_node{n}
52 {
53 }
54 explicit parameter_base(const parameter_base&) = delete;
55 explicit parameter_base(parameter_base&&) = delete;
56 parameter_base& operator=(const parameter_base&) = delete;
57 parameter_base& operator=(parameter_base&&) = delete;
58
59 using callback_index = callback_container<value_callback>::iterator;
60 virtual ~parameter_base();
61
62 ossia::net::node_base& get_node() const noexcept { return m_node; }
63 virtual ossia::net::protocol_base& get_protocol() const noexcept;
64
66
74 virtual void pull_value() = 0;
75
85 virtual std::future<void> pull_value_async();
86
98 virtual void request_value();
99
101 virtual ossia::value value() const = 0;
102
104 ossia::value fetch_value();
105
108 virtual parameter_base& push_value(ossia::value&&) = 0;
109 void push_value_quiet(const ossia::value& v)
110 {
111 set_value_quiet(v);
112 push_value();
113 }
114 void push_value_quiet(ossia::value&& v)
115 {
116 set_value_quiet(std::move(v));
117 push_value();
118 }
119
123
126
128 std::vector<ossia::value> value(const std::vector<ossia::destination_index>&) const;
129
130 virtual ossia::value set_value(const ossia::value&) = 0;
131 virtual ossia::value set_value(ossia::value&&) = 0;
132
134 virtual ossia::value set_value_quiet(const ossia::value& v) { return set_value(v); }
135 virtual ossia::value set_value_quiet(ossia::value&& v)
136 {
137 return set_value(std::move(v));
138 }
139
140 std::optional<ossia::value> get_default_value() const noexcept;
141 void set_default_value(const ossia::value& v);
142
143 virtual val_type get_value_type() const noexcept = 0;
144 virtual parameter_base& set_value_type(val_type) = 0;
145
146 virtual access_mode get_access() const noexcept = 0;
147 virtual parameter_base& set_access(access_mode) = 0;
148
149 virtual const domain& get_domain() const noexcept = 0;
150 virtual parameter_base& set_domain(const domain&) = 0;
151
152 virtual bounding_mode get_bounding() const noexcept = 0;
153 virtual parameter_base& set_bounding(bounding_mode) = 0;
154
155 repetition_filter get_repetition_filter() const noexcept;
156 parameter_base& set_repetition_filter(repetition_filter = repetition_filter::ON);
157 virtual bool filter_value(const ossia::value& val) const noexcept
158 {
159 return m_disabled || m_muted;
160 }
161
162 const ossia::unit_t& get_unit() const noexcept { return m_unit; }
163 virtual parameter_base& set_unit(const ossia::unit_t& v);
164
165 // Shared across the network
166 bool get_disabled() const noexcept;
167 parameter_base& set_disabled(bool);
168
169 // Local only
170 bool get_muted() const noexcept;
171 parameter_base& set_muted(bool);
172
173 bool get_critical() const noexcept;
174 parameter_base& set_critical(bool v);
175
176 parameter_type get_type() const noexcept;
177
178protected:
179 ossia::net::node_base& m_node;
180 unit_t m_unit;
181 bool m_critical{};
182 bool m_disabled{};
183 bool m_muted{};
184 ossia::repetition_filter m_repetitionFilter{ossia::repetition_filter::OFF};
185 parameter_type m_type{};
186};
187
188struct OSSIA_EXPORT parameter_alphabetical_sort
189{
190 bool operator()(
192 const ossia::net::parameter_base* rhs) const noexcept;
193};
194
195inline bool operator==(const parameter_base& lhs, const parameter_base& rhs)
196{
197 return &lhs == &rhs;
198}
199inline bool operator!=(const parameter_base& lhs, const parameter_base& rhs)
200{
201 return &lhs != &rhs;
202}
203}
204}
The callback_container class.
Definition callback_container.hpp:46
The node_base class.
Definition node.hpp:48
The parameter_base class.
Definition ossia/network/base/parameter.hpp:48
virtual ossia::value value() const =0
Clone the current value without any network request.
virtual ossia::value set_value_quiet(const ossia::value &v)
Reimplement to provide a way that does not call the observers.
Definition ossia/network/base/parameter.hpp:134
virtual parameter_base & push_value()=0
const ossia::unit_t & get_unit() const noexcept
by default there is no filter
Definition ossia/network/base/parameter.hpp:162
virtual parameter_base & push_value(const ossia::value &)=0
Sets the value locally, and sends it to the network.
virtual void pull_value()=0
Value getters ///.
The protocol_base class.
Definition protocol.hpp:40
The value class.
Definition value.hpp:173
Definition git_info.h:7
val_type
Enum to represent the types that a value can take.
Definition parameter_properties.hpp:16
repetition_filter
If enabled, sending twice the same value will only send it once by network.
Definition parameter_properties.hpp:70
bounding_mode
Address behaviors at crossing domain boundaries.
Definition parameter_properties.hpp:56
access_mode
Address behaviors at crossing domain boundaries time.
Definition parameter_properties.hpp:46
ossia::small_vector< int32_t, 2 > destination_index
Definition destination_index.hpp:40
parameter_type
Possible types of parameters / ports.
Definition parameter_properties.hpp:34
OSSIA_EXPORT void push_value(const ossia::destination &addr, const ossia::value_with_unit &)
Send a value to a given destination.
Definition ossia/network/base/parameter.cpp:151
domain A domain of values
Definition domain_base.hpp:23
Definition dataspace.hpp:24