From 1830ebd23367a106021eab033c8e4ac0a13f0f52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= Date: Sat, 11 Nov 2023 23:08:18 +0100 Subject: [PATCH] [net] Add parameter type information --- src/ossia/audio/audio_parameter.cpp | 1 + src/ossia/audio/audio_parameter.hpp | 2 +- src/ossia/dataflow/dataflow_fwd.hpp | 4 ++-- src/ossia/gfx/texture_parameter.hpp | 7 ++++++- src/ossia/network/base/parameter.cpp | 5 +++++ src/ossia/network/base/parameter.hpp | 3 +++ src/ossia/network/common/parameter_properties.hpp | 12 ++++++++++++ 7 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/ossia/audio/audio_parameter.cpp b/src/ossia/audio/audio_parameter.cpp index 9f49101200b..bca94e55489 100644 --- a/src/ossia/audio/audio_parameter.cpp +++ b/src/ossia/audio/audio_parameter.cpp @@ -12,6 +12,7 @@ namespace ossia audio_parameter::audio_parameter(net::node_base& n) : ossia::net::parameter_base{n} { + m_type = parameter_type::AUDIO; } void audio_parameter::clone_value(audio_vector& res_vec) const diff --git a/src/ossia/audio/audio_parameter.hpp b/src/ossia/audio/audio_parameter.hpp index f0181daa8da..6de209894f3 100644 --- a/src/ossia/audio/audio_parameter.hpp +++ b/src/ossia/audio/audio_parameter.hpp @@ -16,7 +16,7 @@ class OSSIA_EXPORT audio_parameter : public ossia::net::parameter_base ossia::small_vector, 8> audio; double m_gain{1.}; - audio_parameter(ossia::net::node_base& n); + explicit audio_parameter(ossia::net::node_base& n); virtual ~audio_parameter(); diff --git a/src/ossia/dataflow/dataflow_fwd.hpp b/src/ossia/dataflow/dataflow_fwd.hpp index e83091e7652..6930bf5c089 100644 --- a/src/ossia/dataflow/dataflow_fwd.hpp +++ b/src/ossia/dataflow/dataflow_fwd.hpp @@ -57,8 +57,8 @@ struct midi_delay_line; struct value_delay_line; struct geometry_delay_line; -using data_type - = ossia::nullable_variant; +// using data_type +// = ossia::nullable_variant; using delay_line_type = ossia::nullable_variant< audio_delay_line, midi_delay_line, value_delay_line, geometry_delay_line>; } diff --git a/src/ossia/gfx/texture_parameter.hpp b/src/ossia/gfx/texture_parameter.hpp index 55b6e38b384..45406b41099 100644 --- a/src/ossia/gfx/texture_parameter.hpp +++ b/src/ossia/gfx/texture_parameter.hpp @@ -7,7 +7,12 @@ namespace ossia::gfx class OSSIA_EXPORT texture_parameter : public ossia::net::parameter_base { public: - using parameter_base::parameter_base; + explicit texture_parameter(ossia::net::node_base& n) + : parameter_base{n} + { + m_type = parameter_type::TEXTURE; + } + virtual ~texture_parameter(); void pull_value() override; diff --git a/src/ossia/network/base/parameter.cpp b/src/ossia/network/base/parameter.cpp index a7c98924e74..b7fe9a09248 100644 --- a/src/ossia/network/base/parameter.cpp +++ b/src/ossia/network/base/parameter.cpp @@ -136,6 +136,11 @@ parameter_base& parameter_base::set_critical(bool v) return *this; } +parameter_type parameter_base::get_type() const noexcept +{ + return m_type; +} + value_with_unit get_value(const ossia::destination& d) { ossia::net::parameter_base& addr = d.value.get(); diff --git a/src/ossia/network/base/parameter.hpp b/src/ossia/network/base/parameter.hpp index b3fb2bd090e..66430a4ec61 100644 --- a/src/ossia/network/base/parameter.hpp +++ b/src/ossia/network/base/parameter.hpp @@ -173,6 +173,8 @@ class OSSIA_EXPORT parameter_base : public callback_container bool get_critical() const noexcept; parameter_base& set_critical(bool v); + parameter_type get_type() const noexcept; + protected: ossia::net::node_base& m_node; unit_t m_unit; @@ -180,6 +182,7 @@ class OSSIA_EXPORT parameter_base : public callback_container bool m_disabled{}; bool m_muted{}; ossia::repetition_filter m_repetitionFilter{ossia::repetition_filter::OFF}; + parameter_type m_type{}; }; inline bool operator==(const parameter_base& lhs, const parameter_base& rhs) diff --git a/src/ossia/network/common/parameter_properties.hpp b/src/ossia/network/common/parameter_properties.hpp index 0cafc923971..efb9a471bff 100644 --- a/src/ossia/network/common/parameter_properties.hpp +++ b/src/ossia/network/common/parameter_properties.hpp @@ -27,6 +27,18 @@ enum class val_type : int8_t NONE = std::numeric_limits::max() }; +/** + * @brief Possible types of parameters / ports + */ +enum class parameter_type : int8_t +{ + MESSAGE, + AUDIO, + MIDI, + TEXTURE, + GEOMETRY +}; + /** * @brief Address behaviors at crossing domain boundaries time */