diff --git a/libs/midi++2/midi++/midnam_patch.h b/libs/midi++2/midi++/midnam_patch.h index 18100cf9be..17d3b17f90 100644 --- a/libs/midi++2/midi++/midnam_patch.h +++ b/libs/midi++2/midi++/midnam_patch.h @@ -6,7 +6,7 @@ #include "pbd/xml++.h" #include -#include +#include #include namespace MIDI @@ -18,7 +18,7 @@ namespace Name class Patch : public PBD::Stateful { public: - typedef std::list PatchMidiCommands; + typedef std::vector PatchMidiCommands; Patch() {}; Patch(string a_number, string a_name) : _number(a_number), _name(a_name) {}; @@ -44,7 +44,7 @@ private: class PatchBank : public PBD::Stateful { public: - typedef std::list PatchNameList; + typedef std::vector PatchNameList; PatchBank() {}; virtual ~PatchBank() {}; @@ -67,7 +67,7 @@ class ChannelNameSet : public PBD::Stateful { public: typedef std::set AvailableForChannels; - typedef std::list PatchBanks; + typedef std::vector PatchBanks; ChannelNameSet() {}; virtual ~ChannelNameSet() {}; @@ -109,6 +109,27 @@ private: string _name; }; +class NoteNameList : public PBD::Stateful +{ +public: + typedef std::vector Notes; + NoteNameList() {}; + NoteNameList(string a_name) : _name(a_name) {}; + ~NoteNameList() {}; + + const string& name() const { return _name; } + void set_name(const string a_name) { _name = a_name; } + + const Notes& notes() const { return _notes; } + + XMLNode& get_state (void); + int set_state (const XMLNode& a_node); + +private: + string _name; + Notes _notes; +}; + class CustomDeviceMode : public PBD::Stateful { public: @@ -132,8 +153,11 @@ private: class MasterDeviceNames : public PBD::Stateful { public: - typedef std::list ChannelNameSets; - typedef std::list Models; + typedef std::vector Models; + typedef std::vector CustomDeviceModes; + typedef std::vector ChannelNameSets; + typedef std::vector NoteNameLists; + MasterDeviceNames() {}; virtual ~MasterDeviceNames() {}; @@ -148,9 +172,11 @@ public: int set_state (const XMLNode& a_node); private: - string _manufacturer; - Models _models; - ChannelNameSets _channel_name_sets; + string _manufacturer; + Models _models; + CustomDeviceModes _custom_device_modes; + ChannelNameSets _channel_name_sets; + NoteNameLists _note_name_lists; }; class MIDINameDocument : public PBD::Stateful diff --git a/libs/midi++2/midnam_patch.cc b/libs/midi++2/midnam_patch.cc index dbde6e240c..b9cacdcd96 100644 --- a/libs/midi++2/midnam_patch.cc +++ b/libs/midi++2/midnam_patch.cc @@ -42,7 +42,7 @@ Patch::set_state (const XMLNode& node) XMLNode& Note::get_state (void) { - XMLNode* node = new XMLNode("Patch"); + XMLNode* node = new XMLNode("Note"); node->add_property("Number", _number); node->add_property("Name", _name); @@ -52,13 +52,40 @@ Note::get_state (void) int Note::set_state (const XMLNode& node) { - assert(node.name() == "Patch"); + assert(node.name() == "Note"); _number = node.property("Number")->value(); _name = node.property("Name")->value(); return 0; } +XMLNode& +NoteNameList::get_state (void) +{ + XMLNode* node = new XMLNode("NoteNameList"); + node->add_property("Name", _name); + + return *node; +} + +int +NoteNameList::set_state (const XMLNode& node) +{ + assert(node.name() == "NoteNameList"); + _name = node.property("Name")->value(); + + boost::shared_ptr notes = + node.find("//Note"); + for (XMLSharedNodeList::const_iterator i = notes->begin(); i != notes->end(); ++i) { + Note note; + note.set_state(*(*i)); + _notes.push_back(note); + } + + return 0; +} + + XMLNode& PatchBank::get_state (void) { @@ -188,6 +215,50 @@ CustomDeviceMode::get_state(void) int MasterDeviceNames::set_state(const XMLNode& a_node) { + // Manufacturer + boost::shared_ptr manufacturer = a_node.find("//Manufacturer"); + assert(manufacturer->size() == 1); + _manufacturer = manufacturer->front()->content(); + + // Models + boost::shared_ptr models = a_node.find("//Model"); + assert(models->size() >= 1); + for (XMLSharedNodeList::iterator i = models->begin(); + i != models->end(); + ++i) { + _models.push_back((*i)->content()); + } + + // CustomDeviceModes + boost::shared_ptr custom_device_modes = a_node.find("//CustomDeviceMode"); + for (XMLSharedNodeList::iterator i = custom_device_modes->begin(); + i != custom_device_modes->end(); + ++i) { + CustomDeviceMode custom_device_mode; + custom_device_mode.set_state(*(*i)); + _custom_device_modes.push_back(custom_device_mode); + } + + // ChannelNameSets + boost::shared_ptr channel_name_sets = a_node.find("//ChannelNameSet"); + for (XMLSharedNodeList::iterator i = channel_name_sets->begin(); + i != channel_name_sets->end(); + ++i) { + ChannelNameSet channel_name_set; + channel_name_set.set_state(*(*i)); + _channel_name_sets.push_back(channel_name_set); + } + + // NoteNameLists + boost::shared_ptr note_name_lists = a_node.find("//NoteNameList"); + for (XMLSharedNodeList::iterator i = note_name_lists->begin(); + i != note_name_lists->end(); + ++i) { + NoteNameList note_name_list; + note_name_list.set_state(*(*i)); + _note_name_lists.push_back(note_name_list); + } + return 0; }