More store error correcting fixes.

Working (sometimes...) patch refresh button.


git-svn-id: http://svn.drobilla.net/lad@143 a436a847-0d15-0410-975c-d299462d15a1
This commit is contained in:
dave 2006-09-18 07:19:42 +00:00
parent d52dd9e26f
commit 48871d162c
6 changed files with 47 additions and 26 deletions

View File

@ -52,17 +52,18 @@ ObjectModel::add_metadata(const MetadataMap& data)
{
for (MetadataMap::const_iterator i = data.begin(); i != data.end(); ++i) {
_metadata[i->first] = i->second;
metadata_update_sig.emit(i->first, i->second);
}
}
/** Merge the data of @a model with self, as much as possible.
*
* This will merge the two models, but with any conflict take the version in
* this as correct. The paths of the two models must be equal.
* This will merge the two models, but with any conflict take the value in
* @a model as correct. The paths of the two models MUST be equal.
*/
void
ObjectModel::assimilate(CountedPtr<ObjectModel> model)
ObjectModel::set(CountedPtr<ObjectModel> model)
{
assert(_path == model->path());
@ -71,8 +72,13 @@ ObjectModel::assimilate(CountedPtr<ObjectModel> model)
MetadataMap::const_iterator mine = _metadata.find(other->first);
if (mine == _metadata.end())
_metadata[other->first] = other->second;
if (mine != _metadata.end()) {
cerr << "WARNING: " << _path << "Client/Server data mismatch: " << other->first << endl;
cerr << "Setting server value " << other->second;
}
_metadata[other->first] = other->second;
metadata_update_sig.emit(other->first, other->second);
}
}

View File

@ -69,13 +69,13 @@ protected:
ObjectModel(const Path& path);
virtual void set_path(const Path& p) { _path = p; }
virtual void set_parent(CountedPtr<ObjectModel> p) { _parent = p; }
virtual void set_parent(CountedPtr<ObjectModel> p) { assert(p); _parent = p; }
virtual void add_child(CountedPtr<ObjectModel> c) = 0;
virtual void remove_child(CountedPtr<ObjectModel> c) = 0;
void add_metadata(const MetadataMap& data);
void assimilate(CountedPtr<ObjectModel> model);
void set(CountedPtr<ObjectModel> model);
void set_metadata(const string& key, const Atom& value)
{ _metadata[key] = value; metadata_update_sig.emit(key, value); }

View File

@ -126,7 +126,7 @@ PatchModel::remove_node(CountedPtr<NodeModel> nm)
assert(i->second == nm);
m_nodes.erase(i);
removed_node_sig.emit(nm);
i->second->parent().reset();
//i->second->parent().reset();
return;
}
@ -241,11 +241,14 @@ PatchModel::add_connection(CountedPtr<ConnectionModel> cm)
|| cm->dst_port()->parent()->parent().get() == this);
CountedPtr<ConnectionModel> existing = get_connection(cm->src_port_path(), cm->dst_port_path());
assert(!existing); // Store should have handled this
m_connections.push_back(cm);
new_connection_sig.emit(cm);
if (existing) {
assert(cm->src_port() == existing->src_port());
assert(cm->dst_port() == existing->dst_port());
} else {
m_connections.push_back(cm);
new_connection_sig.emit(cm);
}
}
@ -291,9 +294,9 @@ PatchModel::disable()
bool
PatchModel::polyphonic() const
{
return (!_parent)
? (m_poly > 1)
: (m_poly > 1) && m_poly == ((PatchModel*)_parent.get())->poly() && m_poly > 1;
return (_parent)
? (m_poly > 1) && m_poly == PtrCast<PatchModel>(_parent)->poly() && m_poly > 1
: (m_poly > 1);
}

View File

@ -64,11 +64,10 @@ private:
friend class Store;
PatchModel(const Path& patch_path, size_t internal_poly)
: NodeModel("ingen:patch", patch_path, false ), // FIXME
: NodeModel("ingen:patch", patch_path, false), // FIXME
m_enabled(false),
m_poly(internal_poly)
{
cerr << "FIXME: patch poly\n";
}
void filename(const string& f) { m_filename = f; }

View File

@ -224,9 +224,7 @@ Store::add_object(CountedPtr<ObjectModel> object)
// one (with precedence to the new values).
ObjectMap::iterator existing = m_objects.find(object->path());
if (existing != m_objects.end()) {
cerr << "[Store] Warning: Assimilating " << object->path() << endl;
object->assimilate(existing->second);
existing->second = object;
existing->second->set(object);
} else {
if (object->path() != "/") {
@ -243,6 +241,10 @@ Store::add_object(CountedPtr<ObjectModel> object)
resolve_metadata_orphans(parent);
resolve_orphans(parent);
CountedPtr<PortModel> port = PtrCast<PortModel>(object);
if (port)
resolve_connection_orphans(port);
} else {
add_orphan(object);
}
@ -279,6 +281,9 @@ Store::remove_object(const Path& path)
parent->remove_child(result);
}
}
assert(!object(path));
return result;
} else {
@ -305,16 +310,18 @@ Store::object(const Path& path)
{
assert(path.length() > 0);
map<Path, CountedPtr<ObjectModel> >::iterator i = m_objects.find(path);
if (i == m_objects.end())
if (i == m_objects.end()) {
return CountedPtr<ObjectModel>();
else
return (*i).second;
} else {
assert(i->second->path() == "/" || i->second->parent());
return i->second;
}
}
void
Store::add_plugin(CountedPtr<PluginModel> pm)
{
// FIXME: dupes? assimilate?
// FIXME: dupes? merge, like with objects?
m_plugins[pm->uri()] = pm;
}
@ -452,8 +459,11 @@ Store::connection_event(const Path& src_port_path, const Path& dst_port_path)
CountedPtr<ConnectionModel> dangling_cm(new ConnectionModel(src_port_path, dst_port_path));
if (src_port && src_port->parent() && dst_port && dst_port->parent()) {
if (src_port && dst_port) {
assert(src_port->parent());
assert(dst_port->parent());
CountedPtr<PatchModel> patch = PtrCast<PatchModel>(this->object(dangling_cm->patch_path()));
assert(patch);

View File

@ -52,9 +52,12 @@ ObjectSender::send_patch(ClientInterface* client, const Patch* patch, bool recur
// Send connections
for (List<Connection*>::const_iterator j = patch->connections().begin();
j != patch->connections().end(); ++j)
j != patch->connections().end(); ++j) {
client->connection((*j)->src_port()->path(), (*j)->dst_port()->path());
}
}
// Send metadata