diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2009-12-31 23:43:47 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2009-12-31 23:43:47 +0000 |
commit | 6c717a56e28ebc67bcf041a1ee9887d46700a0e7 (patch) | |
tree | fea823393486d493841d899345cf619ad2f31ca9 /libs/surfaces | |
parent | e00506b0ad7a40f8e876542e40ac85ab1979adb5 (diff) |
new PBD::ControllableDescriptor class to encapsulate parsing of binding URIs and speed up lookup at runtime
git-svn-id: svn://localhost/ardour2/branches/3.0@6427 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/surfaces')
-rw-r--r-- | libs/surfaces/generic_midi/generic_midi_control_protocol.cc | 11 | ||||
-rw-r--r-- | libs/surfaces/generic_midi/midicontrollable.cc | 49 | ||||
-rw-r--r-- | libs/surfaces/generic_midi/midicontrollable.h | 15 |
3 files changed, 24 insertions, 51 deletions
diff --git a/libs/surfaces/generic_midi/generic_midi_control_protocol.cc b/libs/surfaces/generic_midi/generic_midi_control_protocol.cc index 42c5358816..f092fabb59 100644 --- a/libs/surfaces/generic_midi/generic_midi_control_protocol.cc +++ b/libs/surfaces/generic_midi/generic_midi_control_protocol.cc @@ -23,6 +23,7 @@ #include <sstream> #include <algorithm> +#include "pbd/controllable_descriptor.h" #include "pbd/error.h" #include "pbd/failed_constructor.h" #include "pbd/pathscanner.h" @@ -711,11 +712,13 @@ GenericMidiControlProtocol::reset_controllables () MIDIControllable* existingBinding = (*iter); if (!existingBinding->learned()) { - uint32_t rid = existingBinding->rid(); - if (existingBinding->bank_relative()) { - rid += _current_bank * _bank_size; + ControllableDescriptor& desc (existingBinding->descriptor()); + + if (desc.banked()) { + desc.set_bank_offset (_current_bank * _bank_size); } - boost::shared_ptr<Controllable> c = session->controllable_by_rid_and_name (rid, existingBinding->what().c_str()); + + boost::shared_ptr<Controllable> c = session->controllable_by_descriptor (desc); existingBinding->set_controllable (c.get()); } } diff --git a/libs/surfaces/generic_midi/midicontrollable.cc b/libs/surfaces/generic_midi/midicontrollable.cc index 2942a94ad2..d960140958 100644 --- a/libs/surfaces/generic_midi/midicontrollable.cc +++ b/libs/surfaces/generic_midi/midicontrollable.cc @@ -24,6 +24,7 @@ #include <climits> #include "pbd/error.h" +#include "pbd/controllable_descriptor.h" #include "pbd/xml++.h" #include "midi++/port.h" @@ -41,6 +42,7 @@ using namespace ARDOUR; MIDIControllable::MIDIControllable (Port& p, bool is_bistate) : controllable (0) + , _descriptor (0) , _port (p) , bistate (is_bistate) { @@ -55,8 +57,10 @@ MIDIControllable::MIDIControllable (Port& p, bool is_bistate) MIDIControllable::MIDIControllable (Port& p, Controllable& c, bool is_bistate) : controllable (&c) + , _descriptor (0) , _port (p) , bistate (is_bistate) + { _learned = true; /* from controllable */ setting = false; @@ -76,48 +80,9 @@ int MIDIControllable::init (const std::string& s) { _current_uri = s; - - if (!_current_uri.empty()) { - - /* parse URI to get remote control ID and "what" is to be controlled */ - - string::size_type last_slash; - string useful_part; - - if ((last_slash = _current_uri.find_last_of ('/')) == string::npos) { - return -1; - } - - useful_part = _current_uri.substr (last_slash+1); - - char ridstr[64]; - char what[64]; - - if (sscanf (useful_part.c_str(), "rid=%63[^?]?%63s", ridstr, what) != 2) { - return -1; - } - - _what = what; - - /* now parse RID string and determine if its a bank-driven ID */ - - if (strncmp (ridstr, "B-", 2) == 0) { - - if (sscanf (&ridstr[2], "%" PRIu32, &_rid) != 1) { - return -1; - } - - _bank_relative = true; - - } else { - if (sscanf (&ridstr[2], "%" PRIu32, &_rid) != 1) { - return -1; - } - _bank_relative = false; - } - } - - return 0; + delete _descriptor; + _descriptor = new ControllableDescriptor; + return _descriptor->set (s); } void diff --git a/libs/surfaces/generic_midi/midicontrollable.h b/libs/surfaces/generic_midi/midicontrollable.h index a635eaea10..0ce28ecabd 100644 --- a/libs/surfaces/generic_midi/midicontrollable.h +++ b/libs/surfaces/generic_midi/midicontrollable.h @@ -30,12 +30,14 @@ #include "ardour/types.h" -namespace MIDI { - -class Channel; -class Port; -class Parser; +namespace PBD { + class ControllableDescriptor; +} +namespace MIDI { + class Channel; + class Port; + class Parser; } class MIDIControllable : public PBD::Stateful @@ -74,6 +76,8 @@ class MIDIControllable : public PBD::Stateful void set_controllable (PBD::Controllable*); const std::string& current_uri() const { return _current_uri; } + PBD::ControllableDescriptor& descriptor() const { return *_descriptor; } + std::string control_description() const { return _control_description; } XMLNode& get_state (void); @@ -86,6 +90,7 @@ class MIDIControllable : public PBD::Stateful private: PBD::Controllable* controllable; + PBD::ControllableDescriptor* _descriptor; std::string _current_uri; MIDI::Port& _port; bool setting; |