OSSIA
Open Scenario System for Interactive Application
Loading...
Searching...
No Matches
parameter_data.hpp
1#pragma once
4#include <ossia/network/common/complex_type.hpp>
5#include <ossia/network/common/extended_types.hpp>
6#include <ossia/network/dataspace/dataspace.hpp>
7#include <ossia/network/domain/domain.hpp>
8#include <ossia/network/value/value.hpp>
9
10namespace ossia::net
11{
21{
22 parameter_data() = default;
23 parameter_data(const parameter_data&) = default;
24 parameter_data(parameter_data&&) = default;
25 parameter_data& operator=(const parameter_data&) = default;
26 parameter_data& operator=(parameter_data&&) = default;
27
28 parameter_data(std::string n)
29 : name{std::move(n)}
30 {
31 }
32
33 std::string name;
35 ossia::complex_type type;
36 std::optional<ossia::domain> domain;
37 std::optional<ossia::access_mode> access;
38 std::optional<ossia::bounding_mode> bounding;
39 std::optional<ossia::repetition_filter> rep_filter;
40 std::optional<bool> disabled{};
41 std::optional<bool> muted{};
42 std::optional<bool> critical{};
43 unit_t unit;
44
45 extended_attributes extended;
46
47 operator const ossia::extended_attributes&() const { return extended; }
48 operator ossia::extended_attributes&() { return extended; }
49};
50
61{
62public:
63 full_parameter_data() = default;
66 full_parameter_data& operator=(const full_parameter_data&) = default;
67 full_parameter_data& operator=(full_parameter_data&&) = default;
68
69 explicit full_parameter_data(std::string n)
70 : address{std::move(n)}
71 {
72 }
73
74 full_parameter_data(std::string n, ossia::value v)
75 : address{std::move(n)}
76 , val{std::move(v)}
77 {
78 }
79
80 std::string address;
81
82private:
83 ossia::value val;
84 ossia::value previous_val;
85
86public:
87 ossia::val_type type{};
89 ossia::access_mode access{};
90 ossia::bounding_mode bounding{};
91 ossia::repetition_filter rep_filter{};
92 ossia::unit_t unit;
93 bool disabled{};
94 bool muted{};
95 bool critical{};
96
97 extended_attributes extended;
98
99 operator const ossia::extended_attributes&() const { return extended; }
100 operator ossia::extended_attributes&() { return extended; }
101
102 void set_value(const ossia::value& v)
103 {
104 previous_val = std::move(val);
105 val = v;
106 }
107 void set_value(ossia::value&& v)
108 {
109 previous_val = std::move(val);
110 val = std::move(v);
111 }
112
113 bool filter_value(const ossia::value& v) const
114 {
115 return disabled || muted
116 || (get_repetition_filter() == ossia::repetition_filter::ON
117 && v == previous_val);
118 }
119
120 const ossia::value& value() const { return this->val; }
121 ossia::val_type get_value_type() const { return type; }
122 access_mode get_access() const { return access; }
123 const ossia::domain& get_domain() const { return domain; }
124 bounding_mode get_bounding() const { return bounding; }
125 repetition_filter get_repetition_filter() const { return rep_filter; }
126 const ossia::unit_t& get_unit() const { return unit; }
127 bool get_disabled() const { return muted; }
128 bool get_muted() const { return muted; }
129 bool get_critical() const { return critical; }
130};
131}
The value class.
Definition value.hpp:173
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
bool disabled
A disabled node.
Definition node_attributes.hpp:95
bool critical
Means that the node is very important, e.g. a "play" message.
Definition node_attributes.hpp:92
bool muted
Means that the node should not send / receives network messages.
Definition node_attributes.hpp:104
domain A domain of values
Definition domain_base.hpp:23
Full information about a parameter.
Definition parameter_data.hpp:61
The data that can be found inside a parameter.
Definition parameter_data.hpp:21
Definition dataspace.hpp:24