From 0f5a2bafb9f1c3f64256e1899857b2f5cb3d8982 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 18 Dec 2014 07:53:39 +0000 Subject: Work towards engine/GUI separation. git-svn-id: http://svn.drobilla.net/lad/trunk/machina@5495 a436a847-0d15-0410-975c-d299462d15a1 --- src/client/ClientModel.cpp | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'src/client/ClientModel.cpp') diff --git a/src/client/ClientModel.cpp b/src/client/ClientModel.cpp index 17054d4..3a8770f 100644 --- a/src/client/ClientModel.cpp +++ b/src/client/ClientModel.cpp @@ -1,6 +1,6 @@ /* This file is part of Machina. - Copyright 2007-2013 David Robillard + Copyright 2007-2014 David Robillard Machina is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -31,13 +31,31 @@ ClientModel::find(uint64_t id) } } +SPtr +ClientModel::find(uint64_t id) const +{ + SPtr key(new ClientObjectKey(id)); + Objects::const_iterator i = _objects.find(key); + if (i != _objects.end()) { + return *i; + } else { + return SPtr(); + } +} + void -ClientModel::new_object(SPtr object) +ClientModel::new_object(uint64_t id, const Properties& properties) { - Objects::iterator i = _objects.find(object); + SPtr key(new ClientObjectKey(id)); + Objects::iterator i = _objects.find(key); if (i == _objects.end()) { + SPtr object(new ClientObject(id, properties)); _objects.insert(object); signal_new_object.emit(object); + } else { + for (const auto& p : properties) { + (*i)->set(p.first, p.second); + } } } @@ -56,7 +74,7 @@ ClientModel::erase_object(uint64_t id) } void -ClientModel::property(uint64_t id, URIInt key, const Atom& value) +ClientModel::set(uint64_t id, URIInt key, const Atom& value) { SPtr object = find(id); if (object) { @@ -64,5 +82,13 @@ ClientModel::property(uint64_t id, URIInt key, const Atom& value) } } +const Atom& +ClientModel::get(uint64_t id, URIInt key) const +{ + static const Atom null_atom; + SPtr object = find(id); + return object ? object->get(key) : null_atom; +} + } } -- cgit v1.2.1