13
0

* completed MIDI::Name::MasterDeviceNames and implemented its set_state-Method

git-svn-id: svn://localhost/ardour2/branches/3.0@4293 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Hans Baier 2008-12-06 04:38:44 +00:00
parent 110170db95
commit fc73f748b5
2 changed files with 108 additions and 11 deletions

View File

@ -6,7 +6,7 @@
#include "pbd/xml++.h"
#include <string>
#include <list>
#include <vector>
#include <set>
namespace MIDI
@ -18,7 +18,7 @@ namespace Name
class Patch : public PBD::Stateful
{
public:
typedef std::list<Evoral::Event> PatchMidiCommands;
typedef std::vector<Evoral::Event> 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<Patch> PatchNameList;
typedef std::vector<Patch> PatchNameList;
PatchBank() {};
virtual ~PatchBank() {};
@ -67,7 +67,7 @@ class ChannelNameSet : public PBD::Stateful
{
public:
typedef std::set<uint8_t> AvailableForChannels;
typedef std::list<PatchBank> PatchBanks;
typedef std::vector<PatchBank> PatchBanks;
ChannelNameSet() {};
virtual ~ChannelNameSet() {};
@ -109,6 +109,27 @@ private:
string _name;
};
class NoteNameList : public PBD::Stateful
{
public:
typedef std::vector<Note> 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<ChannelNameSet> ChannelNameSets;
typedef std::list<std::string> Models;
typedef std::vector<std::string> Models;
typedef std::vector<CustomDeviceMode> CustomDeviceModes;
typedef std::vector<ChannelNameSet> ChannelNameSets;
typedef std::vector<NoteNameList> 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

View File

@ -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<XMLSharedNodeList> 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<XMLSharedNodeList> manufacturer = a_node.find("//Manufacturer");
assert(manufacturer->size() == 1);
_manufacturer = manufacturer->front()->content();
// Models
boost::shared_ptr<XMLSharedNodeList> 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<XMLSharedNodeList> 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<XMLSharedNodeList> 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<XMLSharedNodeList> 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;
}