Use XMLNode::get_property API in Mackie DeviceInfo class

This commit is contained in:
Tim Mayberry 2016-08-31 15:38:04 +10:00
parent 77b4e041ac
commit 1680811dbf

View file

@ -240,124 +240,96 @@ DeviceInfo::set_state (const XMLNode& node, int /* version */)
/* name is mandatory */ /* name is mandatory */
if ((child = node.child ("Name")) != 0) { if ((child = node.child ("Name")) != 0) {
if ((prop = child->property ("value")) != 0) { if (!child->get_property ("value", _name)) {
_name = prop->value();
} else {
return -1; return -1;
} }
} }
/* strip count is mandatory */ /* strip count is mandatory */
if ((child = node.child ("Strips")) != 0) { if ((child = node.child ("Strips")) != 0) {
if ((prop = child->property ("value")) != 0) { if (!child->get_property ("value", _strip_cnt)) {
if ((_strip_cnt = atoi (prop->value().c_str())) == 0) { _strip_cnt = 8;
_strip_cnt = 8;
}
} }
} else { } else {
return -1; return -1;
} }
if ((child = node.child ("Extenders")) != 0) { if ((child = node.child ("Extenders")) != 0) {
if ((prop = child->property ("value")) != 0) { if (!child->get_property ("value", _extenders)) {
if ((_extenders = atoi (prop->value().c_str())) == 0) { _extenders = 0;
_extenders = 0;
}
} }
} }
if ((child = node.child ("MasterPosition")) != 0) { if ((child = node.child ("MasterPosition")) != 0) {
if ((prop = child->property ("value")) != 0) { if (child->get_property ("value", _master_position)) {
if ((_master_position = atoi (prop->value().c_str())) == 0) { if (_master_position > 0) {
_master_position = 0; _master_position--;
} else if (_master_position > 0) {
_master_position --;
} }
} else {
_master_position = 0;
} }
} }
if ((child = node.child ("TwoCharacterDisplay")) != 0) { if ((child = node.child ("TwoCharacterDisplay")) != 0) {
if ((prop = child->property ("value")) != 0) { child->get_property ("value", _has_two_character_display);
_has_two_character_display = string_is_affirmative (prop->value());
}
} }
if ((child = node.child ("MasterFader")) != 0) { if ((child = node.child ("MasterFader")) != 0) {
if ((prop = child->property ("value")) != 0) { child->get_property ("value", _has_master_fader);
_has_master_fader = string_is_affirmative (prop->value());
}
} }
if ((child = node.child ("TimecodeDisplay")) != 0) { if ((child = node.child ("TimecodeDisplay")) != 0) {
if ((prop = child->property ("value")) != 0) { child->get_property ("value", _has_timecode_display);
_has_timecode_display = string_is_affirmative (prop->value());
}
} else { } else {
_has_timecode_display = false; _has_timecode_display = false;
} }
if ((child = node.child ("GlobalControls")) != 0) { if ((child = node.child ("GlobalControls")) != 0) {
if ((prop = child->property ("value")) != 0) { child->get_property ("value", _has_global_controls);
_has_global_controls = string_is_affirmative (prop->value());
}
} else { } else {
_has_global_controls = false; _has_global_controls = false;
} }
if ((child = node.child ("JogWheel")) != 0) { if ((child = node.child ("JogWheel")) != 0) {
if ((prop = child->property ("value")) != 0) { child->get_property ("value", _has_jog_wheel);
_has_jog_wheel = string_is_affirmative (prop->value());
}
} else { } else {
_has_jog_wheel = false; _has_jog_wheel = false;
} }
if ((child = node.child ("TouchSenseFaders")) != 0) { if ((child = node.child ("TouchSenseFaders")) != 0) {
if ((prop = child->property ("value")) != 0) { child->get_property ("value", _has_touch_sense_faders);
_has_touch_sense_faders = string_is_affirmative (prop->value());
}
} else { } else {
_has_touch_sense_faders = false; _has_touch_sense_faders = false;
} }
if ((child = node.child ("UsesIPMIDI")) != 0) { if ((child = node.child ("UsesIPMIDI")) != 0) {
if ((prop = child->property ("value")) != 0) { child->get_property ("value", _uses_ipmidi);
_uses_ipmidi = string_is_affirmative (prop->value());
}
} else { } else {
_uses_ipmidi = false; _uses_ipmidi = false;
} }
if ((child = node.child ("NoHandShake")) != 0) { if ((child = node.child ("NoHandShake")) != 0) {
if ((prop = child->property ("value")) != 0) { child->get_property ("value", _no_handshake);
_no_handshake = string_is_affirmative (prop->value());
}
} else { } else {
_no_handshake = false; _no_handshake = false;
} }
if ((child = node.child ("HasMeters")) != 0) { if ((child = node.child ("HasMeters")) != 0) {
if ((prop = child->property ("value")) != 0) { child->get_property ("value", _has_meters);
_has_meters = string_is_affirmative (prop->value());
}
} else { } else {
_has_meters = true; _has_meters = true;
} }
if ((child = node.child ("HasSeparateMeters")) != 0) { if ((child = node.child ("HasSeparateMeters")) != 0) {
if ((prop = child->property ("value")) != 0) { child->get_property ("value", _has_separate_meters);
_has_separate_meters = string_is_affirmative (prop->value());
}
} else { } else {
_has_separate_meters = false; _has_separate_meters = false;
} }
if ((child = node.child ("LogicControlButtons")) != 0) { if ((child = node.child ("LogicControlButtons")) != 0) {
if ((prop = child->property ("value")) != 0) { if (child->get_property ("value", _uses_logic_control_buttons)) {
_uses_logic_control_buttons = string_is_affirmative (prop->value());
if (_uses_logic_control_buttons) { if (_uses_logic_control_buttons) {
logic_control_buttons(); logic_control_buttons ();
} else { } else {
mackie_control_buttons (); mackie_control_buttons ();
} }
@ -368,43 +340,37 @@ DeviceInfo::set_state (const XMLNode& node, int /* version */)
XMLNodeConstIterator i; XMLNodeConstIterator i;
const XMLNodeList& nlist (child->children()); const XMLNodeList& nlist (child->children());
std::string name;
for (i = nlist.begin(); i != nlist.end(); ++i) { for (i = nlist.begin(); i != nlist.end(); ++i) {
if ((*i)->name() == "GlobalButton") { if ((*i)->name () == "GlobalButton") {
if ((prop = (*i)->property ("name")) != 0) { if ((*i)->get_property ("name", name)) {
int id = Button::name_to_id (prop->value()); int id = Button::name_to_id (name);
if (id >= 0) { if (id >= 0) {
Button::ID bid = (Button::ID) id; Button::ID bid = (Button::ID)id;
if ((prop = (*i)->property ("id")) != 0) { int32_t id;
int val = strtol (prop->value().c_str(), 0, 0); if ((*i)->get_property ("id", id)) {
std::map<Button::ID,GlobalButtonInfo>::iterator b = _global_buttons.find (bid); std::map<Button::ID, GlobalButtonInfo>::iterator b = _global_buttons.find (bid);
if (b != _global_buttons.end()) { if (b != _global_buttons.end ()) {
b->second.id = val; b->second.id = id;
(*i)->get_property ("label", b->second.label);
if ((prop = (*i)->property ("label")) != 0) {
b->second.label = prop->value();
}
} }
} }
} }
} }
} else if ((*i)->name () == "StripButton") {
} else if ((*i)->name() == "StripButton") { if ((*i)->get_property ("name", name)) {
if ((prop = (*i)->property ("name")) != 0) { int id = Button::name_to_id (name);
int id = Button::name_to_id (prop->value());
if (id >= 0) { if (id >= 0) {
Button::ID bid = (Button::ID) id; Button::ID bid = (Button::ID)id;
if ((prop = (*i)->property ("baseid")) != 0) { int32_t base_id;
int val = strtol (prop->value().c_str(), 0, 0); if ((*i)->get_property ("baseid", base_id)) {
std::map<Button::ID,StripButtonInfo>::iterator b = _strip_buttons.find (bid); std::map<Button::ID, StripButtonInfo>::iterator b = _strip_buttons.find (bid);
if (b != _strip_buttons.end()) { if (b != _strip_buttons.end ()) {
b->second.base_id = val; b->second.base_id = base_id;
} }
} }
} }
} }
} }
} }
} }