summaryrefslogtreecommitdiffstats
path: root/src/libs/client/OSCClientReceiver.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2006-09-08 06:23:25 +0000
committerDavid Robillard <d@drobilla.net>2006-09-08 06:23:25 +0000
commit43d51948ccae71b8f0a1c1710e25cf36da8d7d7c (patch)
treef81e18174cf0a798a908afb954f6595d6c0b72ab /src/libs/client/OSCClientReceiver.h
parent48f87f1f1649fb7e169fdaac2cd38370e8a4a1fa (diff)
downloadingen-43d51948ccae71b8f0a1c1710e25cf36da8d7d7c.tar.gz
ingen-43d51948ccae71b8f0a1c1710e25cf36da8d7d7c.tar.bz2
ingen-43d51948ccae71b8f0a1c1710e25cf36da8d7d7c.zip
Renamed communications classes for consistency.
Removed engine dependency on OSC (mostly). git-svn-id: http://svn.drobilla.net/lad/ingen@120 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/client/OSCClientReceiver.h')
-rw-r--r--src/libs/client/OSCClientReceiver.h120
1 files changed, 120 insertions, 0 deletions
diff --git a/src/libs/client/OSCClientReceiver.h b/src/libs/client/OSCClientReceiver.h
new file mode 100644
index 00000000..60fa9495
--- /dev/null
+++ b/src/libs/client/OSCClientReceiver.h
@@ -0,0 +1,120 @@
+/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard.
+ *
+ * Ingen is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef OSCCLIENTRECEIVER_H
+#define OSCCLIENTRECEIVER_H
+
+#include <cstdlib>
+#include <lo/lo.h>
+#include "interface/ClientInterface.h"
+
+namespace Ingen {
+
+/** Client library */
+namespace Client {
+
+//class NodeModel;
+//class PresetModel;
+
+/* Some boilerplate killing macros... */
+#define LO_HANDLER_ARGS const char* path, const char* types, lo_arg** argv, int argc, lo_message msg
+
+/* Defines a static handler to be passed to lo_add_method, which is a trivial
+ * wrapper around a non-static method that does the real work. Makes a whoole
+ * lot of ugly boiler plate go away */
+#define LO_HANDLER(name) \
+int m_##name##_cb (LO_HANDLER_ARGS);\
+inline static int name##_cb(LO_HANDLER_ARGS, void* osc_listener)\
+{ return ((OSCClientReceiver*)osc_listener)->m_##name##_cb(path, types, argv, argc, msg); }
+
+
+/** Callbacks for "notification band" OSC messages.
+ *
+ * Receives all notification of engine state, but not replies on the "control
+ * band". See OSC namespace documentation for details.
+ *
+ * Right now this class and Comm share the same lo_server_thread and the barrier
+ * between them is a bit odd, but eventually this class will be able to listen
+ * on a completely different port (ie have it's own lo_server_thread) to allow
+ * things like listening to the notification band over TCP while sending commands
+ * on the control band over UDP.
+ *
+ * \ingroup IngenClient
+ */
+class OSCClientReceiver : virtual public Ingen::Shared::ClientInterface
+{
+public:
+ OSCClientReceiver(int listen_port);
+ ~OSCClientReceiver();
+
+ void start();
+ void stop();
+
+ int listen_port() { return _listen_port; }
+ string listen_url() { return lo_server_thread_get_url(_st); }
+
+private:
+ // Prevent copies
+ OSCClientReceiver(const OSCClientReceiver& copy);
+ OSCClientReceiver& operator=(const OSCClientReceiver& copy);
+
+ void setup_callbacks();
+
+ static void error_cb(int num, const char* msg, const char* path);
+ static int generic_cb(const char* path, const char* types, lo_arg** argv, int argc, void* data, void* user_data);
+ static int unknown_cb(const char* path, const char* types, lo_arg** argv, int argc, void* data, void* osc_receiver);
+ /*
+ inline static int om_response_ok_cb(const char* path, const char* types, lo_arg** argv, int argc, void* data, void* comm);
+ int m_om_response_ok_cb(const char* path, const char* types, lo_arg** argv, int argc, void* data);
+ inline static int om_response_error_cb(const char* path, const char* types, lo_arg** argv, int argc, void* data, void* comm);
+ int m_om_response_error_cb(const char* path, const char* types, lo_arg** argv, int argc, void* data);
+*/
+ int _listen_port;
+ lo_server_thread _st;
+
+ // Used for receiving nodes - multiple messages are received before
+ // sending an event to the client (via ModelClientInterface)
+ //bool _receiving_node;
+ //NodeModel* _receiving_node_model;
+ //int32_t _receiving_node_num_ports;
+ //int32_t _num_received_ports;
+
+ LO_HANDLER(error);
+ LO_HANDLER(num_plugins);
+ LO_HANDLER(plugin);
+ LO_HANDLER(plugin_list_end);
+ LO_HANDLER(new_patch);
+ LO_HANDLER(destroyed);
+ LO_HANDLER(patch_enabled);
+ LO_HANDLER(patch_disabled);
+ LO_HANDLER(patch_cleared);
+ LO_HANDLER(object_renamed);
+ LO_HANDLER(connection);
+ LO_HANDLER(disconnection);
+ LO_HANDLER(new_node);
+ LO_HANDLER(new_port);
+ LO_HANDLER(metadata_update);
+ LO_HANDLER(control_change);
+ LO_HANDLER(program_add);
+ LO_HANDLER(program_remove);
+};
+
+
+} // namespace Client
+
+} // namespace Ingen
+
+#endif // OSCCLIENTRECEIVER_H