2#define OSSIA_MAX_AUTOREGISTER 1
5#include "jpatcher_api.h"
7#include <ossia/detail/config.hpp>
11#include "ZeroconfMinuitListener.hpp"
12#include "ZeroconfOscqueryListener.hpp"
14#include "attribute.hpp"
18#include "explorer.hpp"
19#include "fuzzysearch.hpp"
23#include "ossia_object.hpp"
24#include "parameter.hpp"
30#include <ossia/detail/hash_map.hpp>
31#include <ossia/detail/safe_vec.hpp>
32#include <ossia/network/common/websocket_log_sink.hpp>
34#include <ossia-max/src/object_base.hpp>
36#include <ossia-max_export.h>
39OSSIA_MAX_EXPORT
void ossia_router_setup();
40OSSIA_MAX_EXPORT
void ossia_attribute_setup();
41OSSIA_MAX_EXPORT
void ossia_client_setup();
42OSSIA_MAX_EXPORT
void ossia_device_setup();
43OSSIA_MAX_EXPORT
void ossia_logger_setup();
44OSSIA_MAX_EXPORT
void ossia_model_setup();
45OSSIA_MAX_EXPORT
void ossia_parameter_setup();
46OSSIA_MAX_EXPORT
void ossia_remote_setup();
47OSSIA_MAX_EXPORT
void ossia_view_setup();
48OSSIA_MAX_EXPORT
void ossia_ossia_setup();
49OSSIA_MAX_EXPORT
void ossia_explorer_setup();
50OSSIA_MAX_EXPORT
void ossia_search_setup();
51OSSIA_MAX_EXPORT
void ossia_monitor_setup();
52OSSIA_MAX_EXPORT
void ossia_fuzzysearch_setup();
53OSSIA_MAX_EXPORT
void ossia_assert_setup();
54OSSIA_MAX_EXPORT
void ossia_cue_setup();
55OSSIA_MAX_EXPORT
void ossia_equals_setup();
66struct max_msp_log_sink final :
public spdlog::sinks::sink
68 void log(
const spdlog::details::log_msg& msg)
override
70 std::string s(msg.payload.data(), msg.payload.size());
73 case spdlog::level::warn:
74 case spdlog::level::err: {
75 error(
"%s", s.c_str());
80 post(
"%s", s.c_str());
85 void flush()
override { }
87 void set_pattern(
const std::string& pattern)
override { }
88 void set_formatter(std::unique_ptr<spdlog::formatter> sink_formatter)
override { }
91struct patcher_descriptor
93 ossia::safe_set<parameter*> parameters{};
94 ossia::safe_set<remote*> remotes{};
95 ossia::safe_set<attribute*> attributes{};
96 ossia::safe_set<ocue*> cues{};
102 t_object* parent_patcher{};
103 ossia::safe_set<t_object*> subpatchers{};
112 return parameters.empty() && remotes.empty() && attributes.empty() && cues.empty()
113 && model !=
nullptr && view !=
nullptr && device !=
nullptr
114 && client !=
nullptr;
119 return parameters.size() + remotes.size() + attributes.size() + cues.size()
120 + (model ? 1 : 0) + (view ? 1 : 0) + (device ? 1 : 0) + (client ? 1 : 0);
123 bool has_no_master_node()
125 return model ==
nullptr && view ==
nullptr && device ==
nullptr && client ==
nullptr;
131 bool defer_by_default =
true;
132 bool autoregister =
true;
136t_class* ossia_cue_class{};
141 static ossia_max& instance();
142 static const std::shared_ptr<ossia::net::generic_device>& get_default_device()
144 return instance().m_device;
148 static void discover_network_devices(ossia_max* x);
150 template <
typename T>
153 if constexpr(std::is_same<T, parameter>::value)
154 return ossia_parameter_class;
155 else if constexpr(std::is_same<T, remote>::value)
156 return ossia_remote_class;
157 else if constexpr(std::is_same<T, model>::value)
158 return ossia_model_class;
159 else if constexpr(std::is_same<T, view>::value)
160 return ossia_view_class;
161 else if constexpr(std::is_same<T, device>::value)
162 return ossia_device_class;
163 else if constexpr(std::is_same<T, client>::value)
164 return ossia_client_class;
165 else if constexpr(std::is_same<T, attribute>::value)
166 return ossia_attribute_class;
167 else if constexpr(std::is_same<T, ossia_object>::value)
168 return ossia_ossia_class;
169 else if constexpr(std::is_same<T, ossia::max_binding::logger>::value)
170 return ossia_logger_class;
171 else if constexpr(std::is_same<T, ossia::max_binding::explorer>::value)
172 return ossia_explorer_class;
173 else if constexpr(std::is_same<T, ossia::max_binding::monitor>::value)
174 return ossia_monitor_class;
175 else if constexpr(std::is_same<T, ossia::max_binding::search>::value)
176 return ossia_search_class;
177 else if constexpr(std::is_same<T, ossia::max_binding::router>::value)
178 return ossia_router_class;
179 else if constexpr(std::is_same<T, ossia::max_binding::fuzzysearch>::value)
180 return ossia_fuzzysearch_class;
181 else if constexpr(std::is_same<T, ossia::max_binding::oassert>::value)
182 return ossia_assert_class;
183 else if constexpr(
requires { T::max_class; })
188 void set_log_level(t_symbol* log_sym)
190 std::vector<spdlog::string_view_t> vec SPDLOG_LEVEL_NAMES;
191 auto it = std::find(vec.begin(), vec.end(), log_sym->s_name);
194 int level = it - vec.begin();
195 m_log_sink.get()->set_level(
static_cast<spdlog::level::level_enum
>(level));
199 error(
"Unknown log level : %s", log_sym->s_name);
203 t_class* ossia_router_class{};
204 t_class* ossia_client_class{};
205 t_class* ossia_attribute_class{};
206 t_class* ossia_device_class{};
207 t_class* ossia_explorer_class{};
208 t_class* ossia_monitor_class{};
209 t_class* ossia_search_class{};
210 t_class* ossia_fuzzysearch_class{};
211 t_class* ossia_logger_class{};
212 t_class* ossia_model_class{};
213 t_class* ossia_parameter_class{};
214 t_class* ossia_remote_class{};
215 t_class* ossia_view_class{};
216 t_class* ossia_ossia_class{};
217 t_class* ossia_assert_class{};
218 t_class* ossia_equals_class{};
219 static t_class* ossia_patcher_listener_class;
223 ossia::safe_vector<remote*> remotes;
224 ossia::safe_vector<view*> views;
225 ossia::safe_vector<device*> devices;
226 ossia::safe_vector<client*> clients;
227 ossia::safe_vector<logger*> loggers;
229 static ossia::hash_map<ossia::net::node_base*, ossia::safe_set<matcher*>>
231 static std::recursive_mutex s_node_matchers_mut;
234 bool registering_nodes =
false;
236 std::map<t_object*, patcher_descriptor> patchers;
238 static patcher_descriptor& get_patcher_descriptor(t_object* patcher);
239 static void remove_patcher_descriptor(t_object* patcher);
242 static void* s_browse_clock;
244 static ZeroconfOscqueryListener s_zeroconf_oscq_listener;
245 static ZeroconfMinuitListener s_zeroconf_minuit_listener;
247 configuration config;
252 ossia_max(
const ossia_max&) =
delete;
253 ossia_max(ossia_max&&) =
delete;
256 std::shared_ptr<ossia::net::generic_device> m_device;
257 string_map<std::shared_ptr<ossia::websocket_threaded_connection>> m_connections;
258 std::shared_ptr<max_msp_log_sink> m_log_sink;
260 t_object* m_patcher_listener;
266 auto obj = object_alloc(ossia_max::instance().get_class<T>());
270 memcpy(&tmp, obj,
sizeof(t_object));
271 auto x =
new(obj) T{};
272 memcpy(x, &tmp,
sizeof(t_object));
A protocol used to expose a local application's data through multiple other protocols.
Definition local.hpp:22