aboutsummaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/ClientModel.cpp34
-rw-r--r--src/client/ClientModel.hpp16
-rw-r--r--src/client/ClientObject.cpp5
-rw-r--r--src/client/ClientObject.hpp4
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; }