diff options
author | David Robillard <d@drobilla.net> | 2014-12-18 07:53:39 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2014-12-18 07:53:39 +0000 |
commit | 0f5a2bafb9f1c3f64256e1899857b2f5cb3d8982 (patch) | |
tree | f826e3cda65db9990aa9d1b805d634f0e3ce23d5 /src/client | |
parent | 452f0c9a8e020831eedb0dcb8b78b8ca9435b502 (diff) | |
download | machina-0f5a2bafb9f1c3f64256e1899857b2f5cb3d8982.tar.gz machina-0f5a2bafb9f1c3f64256e1899857b2f5cb3d8982.tar.bz2 machina-0f5a2bafb9f1c3f64256e1899857b2f5cb3d8982.zip |
Work towards engine/GUI separation.
git-svn-id: http://svn.drobilla.net/lad/trunk/machina@5495 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/ClientModel.cpp | 34 | ||||
-rw-r--r-- | src/client/ClientModel.hpp | 16 | ||||
-rw-r--r-- | src/client/ClientObject.cpp | 5 | ||||
-rw-r--r-- | src/client/ClientObject.hpp | 4 |
4 files changed, 46 insertions, 13 deletions
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 <http://drobilla.net> + Copyright 2007-2014 David Robillard <http://drobilla.net> 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<const ClientObject> +ClientModel::find(uint64_t id) const +{ + SPtr<ClientObject> key(new ClientObjectKey(id)); + Objects::const_iterator i = _objects.find(key); + if (i != _objects.end()) { + return *i; + } else { + return SPtr<ClientObject>(); + } +} + void -ClientModel::new_object(SPtr<ClientObject> object) +ClientModel::new_object(uint64_t id, const Properties& properties) { - Objects::iterator i = _objects.find(object); + SPtr<ClientObject> key(new ClientObjectKey(id)); + Objects::iterator i = _objects.find(key); if (i == _objects.end()) { + SPtr<ClientObject> 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<ClientObject> 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<const ClientObject> object = find(id); + return object ? object->get(key) : null_atom; +} + } } diff --git a/src/client/ClientModel.hpp b/src/client/ClientModel.hpp index 6840c11..e65fb93 100644 --- a/src/client/ClientModel.hpp +++ b/src/client/ClientModel.hpp @@ -1,6 +1,6 @@ /* This file is part of Machina. - Copyright 2007-2013 David Robillard <http://drobilla.net> + Copyright 2007-2014 David Robillard <http://drobilla.net> 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 @@ -21,6 +21,8 @@ #include <sigc++/sigc++.h> +#include "machina/Model.hpp" + #include "ClientObject.hpp" namespace Raul { @@ -30,14 +32,18 @@ class Atom; namespace machina { namespace client { -class ClientModel +class ClientModel : public Model { public: - void new_object(SPtr<ClientObject> object); + void new_object(uint64_t id, const Properties& properties); + void erase_object(uint64_t id); - void property(uint64_t id, URIInt key, const Atom& value); - SPtr<ClientObject> find(uint64_t id); + SPtr<ClientObject> find(uint64_t id); + SPtr<const ClientObject> find(uint64_t id) const; + + void set(uint64_t id, URIInt key, const Atom& value); + const Atom& get(uint64_t id, URIInt key) const; sigc::signal< void, SPtr<ClientObject> > signal_new_object; sigc::signal< void, SPtr<ClientObject> > signal_erase_object; diff --git a/src/client/ClientObject.cpp b/src/client/ClientObject.cpp index 9481d10..20b50a2 100644 --- a/src/client/ClientObject.cpp +++ b/src/client/ClientObject.cpp @@ -1,6 +1,6 @@ /* This file is part of Machina. - Copyright 2007-2013 David Robillard <http://drobilla.net> + Copyright 2007-2014 David Robillard <http://drobilla.net> 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 @@ -21,9 +21,10 @@ namespace machina { namespace client { -ClientObject::ClientObject(uint64_t id) +ClientObject::ClientObject(uint64_t id, const Properties& properties) : _id(id) , _view(NULL) + , _properties(properties) {} ClientObject::ClientObject(const ClientObject& copy, uint64_t id) diff --git a/src/client/ClientObject.hpp b/src/client/ClientObject.hpp index cf00a2b..6520b11 100644 --- a/src/client/ClientObject.hpp +++ b/src/client/ClientObject.hpp @@ -1,6 +1,6 @@ /* This file is part of Machina. - Copyright 2007-2013 David Robillard <http://drobilla.net> + Copyright 2007-2014 David Robillard <http://drobilla.net> 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 @@ -30,7 +30,7 @@ namespace client { class ClientObject { public: - explicit ClientObject(uint64_t id); + explicit ClientObject(uint64_t id, const Properties& properties={}); ClientObject(const ClientObject& copy, uint64_t id); inline uint64_t id() const { return _id; } |