3#include "ext_critical.h"
7#include <ossia/detail/config.hpp>
10#include <ossia/detail/optional.hpp>
11#include <ossia/detail/safe_vec.hpp>
12#include <ossia/network/base/node.hpp>
13#include <ossia/network/base/osc_address.hpp>
14#include <ossia/network/base/value_callback.hpp>
15#include <ossia/network/common/path.hpp>
16#include <ossia/network/dataspace/dataspace.hpp>
17#include <ossia/network/generic/generic_device.hpp>
22#define OSSIA_MAX_MAX_ATTR_SIZE 256
30#pragma mark t_object_base structure declaration
32enum class object_class
54 object_base*
object{};
57 t_symbol* classname{};
60 friend bool operator<(search_result a, search_result b) {
return a.level < b.level; }
79 bool m_local_mute{
false};
82 ossia::net::address_scope m_addr_scope{};
83 object_class m_otype{};
86 void* m_highlight_clock{};
91 std::shared_ptr<ossia::net::generic_device> m_device{};
92 using matcher_vector = std::vector<std::shared_ptr<matcher>>;
93 matcher_vector m_matchers{};
94 std::vector<matcher*> m_node_selection{};
95 std::optional<ossia::traversal::path> m_selection_path{};
96 static void class_setup(t_class* c);
98 void fill_selection();
99 void update_path(ossia::net::generic_device* explicit_device =
nullptr);
100 void get_hierarchy();
102 void set_description();
106 void set_recall_safe();
109 object_base* find_parent_object();
113 find_parent_object_recursively(t_object* patcher,
bool look_for_model_view);
115 static void get_description(object_base* x, std::vector<matcher*> nodes);
116 static void get_tags(object_base* x, std::vector<matcher*> nodes);
117 static void get_priority(object_base* x, std::vector<matcher*> nodes);
118 static void get_hidden(object_base* x, std::vector<matcher*> nodes);
119 static void get_zombie(object_base* x, std::vector<matcher*> nodes);
120 static void get_mess_cb(object_base* x, t_symbol* s);
121 static void select_mess_cb(object_base* x, t_symbol* s,
int argc, t_atom* argv);
122 static void get_recall_safe(object_base* x, std::vector<matcher*> nodes);
126 t_symbol* m_tags[OSSIA_MAX_MAX_ATTR_SIZE] = {{}};
127 t_symbol* m_description{};
131 long m_recall_safe{};
137 t_object* m_patcher{};
140 long m_description_size{};
143 std::vector<search_result> m_found_parameters{};
144 std::vector<search_result> m_found_models{};
154 std::mutex m_bind_mutex;
156 std::vector<t_object*> m_patcher_hierarchy;
159 static void update_attribute(
162 notify(object_base* x, t_symbol* s, t_symbol* msg,
void* sender,
void* data);
166 static void defer_set_output(object_base* x, t_symbol* s,
int argc, t_atom* argv);
167 static void set(object_base* x, t_symbol* s,
int argc, t_atom* argv);
168 static void get_address(object_base* x, std::vector<matcher*> nodes);
169 static void lock_and_touch(object_base* x, t_symbol* s);
170 static void loadbang(object_base* x);
171 void save_children_state();
173 void clear_and_init_registration();
175 static void reset_color(object_base* x);
178 void set_matchers_index();
180 std::vector<std::string> m_paths{};
182 std::vector<std::shared_ptr<matcher>> find_or_create_matchers(ossia::net::generic_device* device_to_use =
nullptr);
186 void remove_matcher(
const std::shared_ptr<matcher>& m);
188 [[nodiscard]] matcher_vector::iterator remove_matcher(matcher_vector::iterator m);
190 std::map<std::string, ossia::value> m_value_map{};
193 std::vector<std::shared_ptr<matcher>> find_parent_nodes();
194 void load_configuration(ossia_max& omax);
195 void create_patcher_hierarchy(ossia_max& omax);
196 unsigned long poly_index();
197 void make_global_paths(
const std::string& name);
201#pragma mark Utilities
206 std::vector<t_atom>& data;
207 void operator()(impulse)
const
210 atom_setsym(&a, _sym_bang);
214 void operator()(int32_t i)
const
221 void operator()(int64_t i)
const
228 void operator()(
float f)
const
231 atom_setfloat(&a, f);
235 void operator()(
bool b)
const
238 float f = b ? 1. : 0.;
239 atom_setfloat(&a, f);
243 void operator()(
auto*) const noexcept = delete;
245 void operator()(const
char* str)
const
247 t_symbol* s = gensym(str);
253 void operator()(std::string_view str)
const
255 t_symbol* s = gensym(str.data());
261 template <std::
size_t N>
262 void operator()(std::array<float, N> vec)
const
264 data.reserve(data.size() + N);
265 for(std::size_t i = 0; i < N; i++)
268 atom_setfloat(&a, vec[i]);
273 void operator()(
const std::vector<ossia::value>& t)
const
275 data.reserve(data.size() + t.size());
276 for(
const auto& v : t)
280 void operator()(
const ossia::value_map_type& t)
const { }
282 template <
typename... T>
283 requires(
sizeof...(T) > 1)
284 OSSIA_INLINE
void operator()(T&&... t)
289 void operator()()
const { }
293write_message(std::vector<t_atom>& va,
void* out, t_symbol* sym,
auto&&... args)
298 outlet_anything(out, sym, va.size(), va.data());
301inline void write_message(
302 std::vector<t_atom>& va,
void* out, t_symbol* prefix, t_symbol* sym,
auto&&... args)
306 write_message(va, out, sym, args...);
312 vm(std::string_view(sym->s_name));
314 outlet_anything(out, prefix, va.size(), va.data());
324 void set_out(t_atom& a)
const
330 defer_low((t_object*)x, (method)object_base::defer_set_output, _sym_set, 1, &a);
334 outlet_anything(x->m_set_out, _sym_set, 1, &a);
339 void set_out(
int N, t_atom* a)
const
345 defer_low((t_object*)x, (method)object_base::defer_set_output, _sym_set, N, a);
349 outlet_anything(x->m_set_out, _sym_set, N, a);
354 void operator()(impulse)
const
356 outlet_bang(x->m_data_out);
359 outlet_bang(x->m_set_out);
362 void operator()(int32_t i)
const
366 outlet_int(x->m_data_out, i);
371 void operator()(
float f)
const
375 atom_setfloat(&a, f);
376 if(x && x->m_data_out)
378 outlet_float(x->m_data_out, f);
383 void operator()(
bool b)
const { (*this)(b ? 1 : 0); }
385 void operator()(
const std::string& str)
const
387 t_symbol* s = gensym(str.c_str());
391 outlet_anything(x->m_data_out, s, 0,
nullptr);
396 template <std::
size_t N>
397 void operator()(std::array<float, N> vec)
const
401 for(
int i = 0; i < N; i++)
402 atom_setfloat(a + i, vec[i]);
403 outlet_list(x->m_data_out, _sym_list, N, a);
408 void operator()(
const std::vector<ossia::value>& t)
const
410 std::vector<t_atom> va;
416 for(
const auto& v : t)
419 t_atom* list_ptr = !va.empty() ? va.data() :
nullptr;
421 outlet_list(x->m_data_out, _sym_list, va.size(), list_ptr);
423 set_out(va.size(), list_ptr);
426 void operator()(
const ossia::value_map_type& t)
const { }
428 void operator()()
const
430 object_error((t_object*)x,
"%s received an invalid data", x->m_name->s_name);
The node_base class.
Definition node.hpp:48
The parameter_base class.
Definition ossia/network/base/parameter.hpp:48
The value class.
Definition value.hpp:173