return val;
}
-void
-ARDOUR_UI::TransportControllable::set_id (const string& str)
-{
- _id = str;
-}
-
void
ARDOUR_UI::setup_profile ()
{
void set_value (double);
double get_value (void) const;
- void set_id (const std::string&);
-
ARDOUR_UI& ui;
ToggleType type;
};
}
/* register for undo history */
- _session->register_with_memento_command_factory(_id, this);
+ _session->register_with_memento_command_factory(id(), this);
ActionManager::ui_manager->signal_pre_activate().connect (sigc::mem_fun (*this, &Editor::action_pre_activated));
int x, y;
Gdk::Geometry g;
- if ((prop = node.property ("id")) != 0) {
- _id = prop->value ();
- }
+ set_id (node);
g.base_width = default_width;
g.base_height = default_height;
XMLNode* node = new XMLNode ("Editor");
char buf[32];
- _id.print (buf, sizeof (buf));
+ id().print (buf, sizeof (buf));
node->add_property ("id", buf);
if (is_realized()) {
{
}
-void
-ShuttleControl::ShuttleControllable::set_id (const std::string& str)
-{
- _id = str;
-}
-
void
ShuttleControl::ShuttleControllable::set_value (double val)
{
void set_value (double);
double get_value (void) const;
- void set_id (const std::string&);
-
ShuttleControl& sc;
};
}
TimeAxisViewItem::TimeAxisViewItem (const TimeAxisViewItem& other)
- : Selectable (other)
+ : trackable (other)
+ , Selectable (other)
, PBD::ScopedConnectionList()
, trackview (other.trackview)
, _recregion (other._recregion)
if (read ((*chan)->playback_buf->buffer() + overwrite_offset, mixdown_buffer, gain_buffer, start, to_read, *chan, n, reversed)) {
error << string_compose(_("AudioDiskstream %1: when refilling, cannot read %2 from playlist at frame %3"),
- _id, size, playback_sample) << endmsg;
+ id(), size, playback_sample) << endmsg;
goto out;
}
if (read ((*chan)->playback_buf->buffer(), mixdown_buffer, gain_buffer,
start, cnt, *chan, n, reversed)) {
error << string_compose(_("AudioDiskstream %1: when refilling, cannot read %2 from playlist at frame %3"),
- _id, size, playback_sample) << endmsg;
+ id(), size, playback_sample) << endmsg;
goto out;
}
}
this_read = min(cnt,this_read);
if (audio_playlist()->read (buf+offset, mixdown_buffer, gain_buffer, start, this_read, channel) != this_read) {
- error << string_compose(_("AudioDiskstream %1: cannot read %2 from playlist at frame %3"), _id, this_read,
+ error << string_compose(_("AudioDiskstream %1: cannot read %2 from playlist at frame %3"), id(), this_read,
start) << endmsg;
return -1;
}
}
if ((!(*chan)->write_source) || (*chan)->write_source->write (vector.buf[0], to_write) != to_write) {
- error << string_compose(_("AudioDiskstream %1: cannot write to disk"), _id) << endmsg;
+ error << string_compose(_("AudioDiskstream %1: cannot write to disk"), id()) << endmsg;
return -1;
}
to_write = min ((framecnt_t)(disk_io_chunk_frames - to_write), (framecnt_t) vector.len[1]);
if ((*chan)->write_source->write (vector.buf[1], to_write) != to_write) {
- error << string_compose(_("AudioDiskstream %1: cannot write to disk"), _id) << endmsg;
+ error << string_compose(_("AudioDiskstream %1: cannot write to disk"), id()) << endmsg;
return -1;
}
root->add_property ("automation-id", EventTypeMap::instance().to_symbol(_parameter));
- root->add_property ("id", _id.to_s());
+ root->add_property ("id", id().to_s());
snprintf (buf, sizeof (buf), "%.12g", _default_value);
root->add_property ("default", buf);
return -1;
}
- if ((prop = node.property ("id")) != 0) {
- _id = prop->value ();
+ if (set_id (node)) {
/* update session AL list */
AutomationListCreated(this);
}
PropertyChange what_changed;
framepos_t val;
- if ((prop = node.property (X_("id")))) {
- _id = prop->value();
- }
+ set_id (node);
if ((prop = node.property ("position")) != 0) {
sscanf (prop->value().c_str(), "%" PRId64, &val);
}
if (deprecated_io_node) {
- if ((prop = deprecated_io_node->property ("id")) != 0) {
- _id = prop->value ();
- }
+ set_id (*deprecated_io_node);
} else {
- if ((prop = node.property ("id")) != 0) {
- _id = prop->value ();
- }
+ set_id (node);
}
if ((prop = node.property ("flags")) != 0) {
assert(_default_type != DataType::NIL);
}
- if ((prop = node.property ("id")) != 0) {
- _id = prop->value ();
- }
+ set_id (node);
if ((prop = node.property ("direction")) != 0) {
_direction = (Direction) string_2_enum (prop->value(), _direction);
assert(_default_type != DataType::NIL);
}
- if ((prop = node.property ("id")) != 0) {
- _id = prop->value ();
- }
+ set_id (node);
_direction = in ? Input : Output;
return -1;
}
- if ((prop = node.property ("id")) == 0) {
+ if (!set_id (node)) {
warning << _("XML node for Location has no ID information") << endmsg;
- } else {
- _id = prop->value ();
}
if ((prop = node.property ("name")) == 0) {
XMLNode* root = t->root ();
for (XMLNodeList::const_iterator i = root->children().begin(); i != root->children().end(); ++i) {
- XMLProperty* uri = (*i)->property (X_("uri"));
XMLProperty* label = (*i)->property (X_("label"));
- assert (uri);
assert (label);
if (label->value() != r.label) {
if (midi_playlist()->read (*_playback_buf, start, this_read) != this_read) {
error << string_compose(
_("MidiDiskstream %1: cannot read %2 from playlist at frame %3"),
- _id, this_read, start) << endmsg;
+ id(), this_read, start) << endmsg;
return -1;
}
if (record_enabled() && ((total > disk_io_chunk_frames) || force_flush)) {
if (_write_source->midi_write (*_capture_buf, get_capture_start_frame (0), to_write) != to_write) {
- error << string_compose(_("MidiDiskstream %1: cannot write to disk"), _id) << endmsg;
+ error << string_compose(_("MidiDiskstream %1: cannot write to disk"), id()) << endmsg;
return -1;
}
}
plist = node.properties();
+ set_id (node);
+
for (piter = plist.begin(); piter != plist.end(); ++piter) {
prop = *piter;
if (prop->name() == X_("name")) {
_name = prop->value();
_set_sort_id ();
- } else if (prop->name() == X_("id")) {
- _id = prop->value();
} else if (prop->name() == X_("orig-diskstream-id")) {
_orig_diskstream_id = prop->value ();
} else if (prop->name() == X_("frozen")) {
node.add_property ("offset", buf);
snprintf (buf, sizeof (buf), "%" PRIu64, _playlist_length);
node.add_property ("length", buf);
- node.add_property ("original", _id.to_s());
+ node.add_property ("original", id().to_s());
node.add_child_nocopy (_playlist->get_state());
}
sscanf (prop->value().c_str(), "%" PRIu64, &_playlist_length);
+ /* XXX not quite sure why we set our ID back to the "original" one
+ here. october 2011, paul
+ */
+
if ((prop = node.property (X_("original"))) == 0) {
throw failed_constructor ();
}
- _id = prop->value();
+ set_id (prop->value());
_level = _playlist->max_source_level () + 1;
if (plug) {
add_plugin (plug);
create_automatable_parameters ();
-
- Glib::Mutex::Lock em (_session.engine().process_lock());
- IO::PortCountChanged (max(input_streams(), output_streams()));
}
}
// state. We can't call Processor::set_state() until
// the plugins themselves are created and added.
- if ((prop = node.property ("id")) != 0) {
- _id = prop->value();
- }
+ set_id (node);
if (_plugins.empty()) {
/* if we are adding the first plugin, we will need to set
set_name (prop->value ());
}
- if ((prop = (*i)->property ("id")) != 0) {
- _id = prop->value ();
- }
+ set_id (**i);
if ((prop = (*i)->property ("active")) != 0) {
bool const a = string_is_affirmative (prop->value ());
Processor::set_name (prop->value());
}
- // may not exist for legacy 3.0 sessions
- if ((prop = node.property ("id")) != 0) {
- _id = prop->value();
- }
+ set_id (node);
XMLNodeList nlist = node.children();
XMLNodeIterator niter;
add_properties (*node);
- _id.print (buf, sizeof (buf));
+ id().print (buf, sizeof (buf));
node->add_property ("id", buf);
node->add_property ("type", _type.to_string());
what_changed = set_values (node);
- if ((prop = node.property (X_("id")))) {
- _id = prop->value();
- }
+ set_id (node);
if (_position_lock_style == MusicTime) {
if ((prop = node.property ("bbt-position")) == 0) {
Route::set_name (prop->value());
}
- if ((prop = node.property ("id")) != 0) {
- _id = prop->value ();
- }
+ set_id (node);
if ((prop = node.property (X_("flags"))) != 0) {
_flags = Flag (string_2_enum (prop->value(), _flags));
Route::set_name (prop->value ());
}
- if ((prop = child->property (X_("id"))) != 0) {
- _id = prop->value ();
- }
+ set_id (*child);
if ((prop = child->property (X_("active"))) != 0) {
bool yn = string_is_affirmative (prop->value());
const XMLProperty *prop;
- if ((prop = node.property ("id")) != 0) {
- _id = prop->value();
- }
-
+ set_id (node);
set_values (node);
if ((prop = node.property ("routes")) != 0) {
node->add_property ("name", name());
node->add_property ("type", _type.to_string());
node->add_property (X_("flags"), enum_2_string (_flags));
- _id.print (buf, sizeof (buf));
+ id().print (buf, sizeof (buf));
node->add_property ("id", buf);
if (_timestamp != 0) {
return -1;
}
- if ((prop = node.property ("id")) != 0) {
- _id = prop->value ();
- } else {
+ if (!set_id (node)) {
return -1;
}
s = _session.analysis_dir ();
parts.push_back (s);
- s = _id.to_s();
+ s = id().to_s();
s += '.';
s += TransientDetector::operational_identifier();
parts.push_back (s);
char buf[64];
node->add_property (X_("name"), _name); // not reloaded from XML state, just there to look at
- _id.print (buf, sizeof (buf));
+ id().print (buf, sizeof (buf));
node->add_property (X_("id"), buf);
node->add_property (X_("flags"), enum_2_string (_flags));
snprintf (buf, sizeof (buf), "%2.12f", get_value());
Stateful::save_extra_xml (node);
- if ((prop = node.property (X_("id"))) != 0) {
- _id = prop->value();
- } else {
+ if (!set_id (node)) {
error << _("Controllable state node has no ID property") << endmsg;
return -1;
}
ID::ID ()
{
- Glib::Mutex::Lock lm (*counter_lock);
- _id = _counter++;
+ reset ();
}
ID::ID (const ID& other)
string_assign (str);
}
+void
+ID::reset ()
+{
+ Glib::Mutex::Lock lm (*counter_lock);
+ _id = _counter++;
+}
+
int
ID::string_assign (string str)
{
ID (std::string);
ID (const ID&);
+ void reset ();
+
bool operator== (const ID& other) const {
return _id == other._id;
}
void save_extra_xml (const XMLNode&);
const PBD::ID& id() const { return _id; }
-
+ bool set_id (const XMLNode&);
+ void set_id (const std::string&);
+ void reset_id ();
+
/* history management */
void clear_changes ();
XMLNode *_extra_xml;
XMLNode *_instant_xml;
- PBD::ID _id;
int32_t _frozen;
PBD::PropertyChange _pending_changed;
Glib::Mutex _lock;
*/
virtual void mid_thaw (const PropertyChange&) { }
bool property_changes_suspended() const { return g_atomic_int_get (&_frozen) > 0; }
+
+ private:
+ PBD::ID _id;
};
} // namespace PBD
}
}
+bool
+Stateful::set_id (const XMLNode& node)
+{
+ const XMLProperty* prop;
+
+ if ((prop = node.property ("id")) != 0) {
+ _id = prop->value ();
+ return true;
+ }
+
+ return false;
+}
+
+void
+Stateful::reset_id ()
+{
+ _id = ID ();
+}
+
+void
+Stateful::set_id (const string& str)
+{
+ _id = str;
+}
} // namespace PBD