2 * Plugin introspection interface
4 * Copyright (C) 2008 Krzysztof Foltman
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General
17 * Public License along with this program; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
19 * Boston, MA 02111-1307, USA.
22 #ifndef __CALF_PLUGININFO_H
23 #define __CALF_PLUGININFO_H
27 namespace calf_plugins
{
29 /// A sink to send information about an audio port
30 struct plain_port_info_iface
32 /// Called if it's an input port
33 virtual plain_port_info_iface
& input() { return *this; }
34 /// Called if it's an output port
35 virtual plain_port_info_iface
& output() { return *this; }
36 virtual plain_port_info_iface
& lv2_ttl(const std::string
&text
) { return *this; }
37 virtual ~plain_port_info_iface() {}
40 /// A sink to send information about a control port (very incomplete, missing stuff: units, integer, boolean, toggled, notAutomatic, notGUI...)
41 struct control_port_info_iface
43 /// Called if it's an input port
44 virtual control_port_info_iface
& input() { return *this; }
45 /// Called if it's an output port
46 virtual control_port_info_iface
& output() { return *this; }
47 /// Called to mark the port as using linear range [from, to]
48 virtual control_port_info_iface
& lin_range(double from
, double to
) { return *this; }
49 /// Called to mark the port as using log range [from, to]
50 virtual control_port_info_iface
& log_range(double from
, double to
) { return *this; }
51 virtual control_port_info_iface
& toggle() { return *this; }
52 virtual control_port_info_iface
& trigger() { return *this; }
53 virtual control_port_info_iface
& integer() { return *this; }
54 virtual control_port_info_iface
& lv2_ttl(const std::string
&text
) { return *this; }
55 virtual control_port_info_iface
& polymorphic() { return lv2_ttl("a poly:PolymorphicPort ;"); }
56 virtual control_port_info_iface
& poly_audio() { return lv2_ttl("poly:supportsType lv2:AudioPort ;"); }
57 virtual ~control_port_info_iface() {}
60 /// A sink to send information about a plugin
61 struct plugin_info_iface
63 /// Set plugin names (ID, name and label)
64 virtual void names(const std::string
&name
, const std::string
&label
, const std::string
&category
, const std::string
µname
= std::string()) {}
65 /// Add an audio port (returns a sink which accepts further description)
66 virtual plain_port_info_iface
&audio_port(const std::string
&id
, const std::string
&name
, const std::string
µname
= std::string("N/A"))=0;
67 /// Add an event port (returns a sink which accepts further description)
68 virtual plain_port_info_iface
&event_port(const std::string
&id
, const std::string
&name
, const std::string
µname
= std::string("N/A"))=0;
69 /// Add a control port (returns a sink which accepts further description)
70 virtual control_port_info_iface
&control_port(const std::string
&id
, const std::string
&name
, double def_value
, const std::string
µname
= "N/A")=0;
71 /// Add arbitrary TTL clauses
72 virtual void lv2_ttl(const std::string
&text
) {}
73 /// Add small plugin GUI
74 virtual void has_gui() { lv2_ttl("uiext:ui <http://calf.sourceforge.net/small_plugins/gui/gtk2-gui> ;"); }
75 /// Called after plugin has reported all the information
76 virtual void finalize() {}
77 virtual ~plugin_info_iface() {}
80 struct plugin_port_type_grabber
: public plugin_info_iface
, public control_port_info_iface
85 plain_port_info_iface pp
;
86 control_port_info_iface cp
;
88 plugin_port_type_grabber(uint32_t &_target
) : target(_target
), index(0) { target
= 0; }
90 virtual plain_port_info_iface
&audio_port(const std::string
&id
, const std::string
&name
, const std::string
µname
= std::string("N/A")) { target
|= (1 << index
); index
++; return pp
; }
91 virtual plain_port_info_iface
&event_port(const std::string
&id
, const std::string
&name
, const std::string
µname
= std::string("N/A")) { index
++; return pp
; }
92 virtual control_port_info_iface
&control_port(const std::string
&id
, const std::string
&name
, double def_value
, const std::string
µname
= "N/A") { index
++; return cp
; }
95 /// A sink to send information about plugins
96 struct plugin_list_info_iface
98 /// Add an empty plugin object and return the sink to be filled with information
99 virtual plugin_info_iface
&plugin(const std::string
&id
) = 0;
100 virtual ~plugin_list_info_iface() {}