From 21365044f63e70deb2e8bd0685349aad6ea14e85 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 10 Jan 2011 23:50:45 +0000 Subject: Add missing files. git-svn-id: http://svn.drobilla.net/lad/trunk/machina@2824 a436a847-0d15-0410-975c-d299462d15a1 --- src/client/ClientModel.cpp | 63 +++++++++++++++++++++++++++++++++++++++++ src/client/ClientModel.hpp | 57 +++++++++++++++++++++++++++++++++++++ src/client/ClientObject.cpp | 55 ++++++++++++++++++++++++++++++++++++ src/client/ClientObject.hpp | 69 +++++++++++++++++++++++++++++++++++++++++++++ src/client/wscript | 18 ++++++++++++ 5 files changed, 262 insertions(+) create mode 100644 src/client/ClientModel.cpp create mode 100644 src/client/ClientModel.hpp create mode 100644 src/client/ClientObject.cpp create mode 100644 src/client/ClientObject.hpp create mode 100644 src/client/wscript (limited to 'src/client') diff --git a/src/client/ClientModel.cpp b/src/client/ClientModel.cpp new file mode 100644 index 0000000..f26d853 --- /dev/null +++ b/src/client/ClientModel.cpp @@ -0,0 +1,63 @@ +/* This file is part of Machina. + * Copyright (C) 2010 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 Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Machina is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Machina. If not, see . + */ + +#include "ClientModel.hpp" + +namespace Machina { +namespace Client { + +SharedPtr +ClientModel::find(uint64_t id) +{ + SharedPtr key(new ClientObjectKey(id)); + Objects::iterator i = _objects.find(key); + if (i != _objects.end()) + return *i; + else + return SharedPtr(); +} + +void +ClientModel::new_object(SharedPtr object) +{ + _objects.insert(object); + signal_new_object.emit(object); +} + +void +ClientModel::erase_object(uint64_t id) +{ + SharedPtr key(new ClientObjectKey(id)); + Objects::iterator i = _objects.find(key); + if (i == _objects.end()) + return; + + signal_erase_object.emit(*i); + (*i)->set_view(SharedPtr()); + _objects.erase(i); +} + +void +ClientModel::property(uint64_t id, URIInt key, const Raul::Atom& value) +{ + SharedPtr object = find(id); + if (object) + object->set(key, value); +} + +} +} diff --git a/src/client/ClientModel.hpp b/src/client/ClientModel.hpp new file mode 100644 index 0000000..49f14a5 --- /dev/null +++ b/src/client/ClientModel.hpp @@ -0,0 +1,57 @@ +/* This file is part of Machina. + * Copyright (C) 2010 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 Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Machina is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Machina. If not, see . + */ + +#ifndef MACHINA_CLIENTMODEL_HPP +#define MACHINA_CLIENTMODEL_HPP + +#include + +#include + +#include "ClientObject.hpp" + +namespace Raul { class Atom; } + +namespace Machina { +namespace Client { + +class ClientModel { +public: + void new_object(SharedPtr object); + void erase_object(uint64_t id); + void property(uint64_t id, URIInt key, const Raul::Atom& value); + + SharedPtr find(uint64_t id); + + sigc::signal< void, SharedPtr > signal_new_object; + sigc::signal< void, SharedPtr > signal_erase_object; + +private: + struct ClientObjectComparator { + inline bool operator()(SharedPtr lhs, SharedPtr rhs) const { + return lhs->id() < rhs->id(); + } + }; + + typedef std::set, ClientObjectComparator> Objects; + Objects _objects; +}; + +} +} + +#endif // MACHINA_CLIENTMODEL_HPP diff --git a/src/client/ClientObject.cpp b/src/client/ClientObject.cpp new file mode 100644 index 0000000..41f8080 --- /dev/null +++ b/src/client/ClientObject.cpp @@ -0,0 +1,55 @@ +/* This file is part of Machina. + * Copyright (C) 2010 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 Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Machina is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Machina. If not, see . + */ + +#include + +#include "ClientObject.hpp" + +namespace Machina { +namespace Client { + +ClientObject::ClientObject(uint64_t id) + : _id(id) +{ +} + +ClientObject::ClientObject(const ClientObject& copy, uint64_t id) + : _id(id) + , _properties(copy._properties) +{ +} + +void +ClientObject::set(URIInt key, const Raul::Atom& value) +{ + _properties[key] = value; + signal_property.emit(key, value); +} + +const Raul::Atom& +ClientObject::get(URIInt key) const +{ + static const Raul::Atom null_atom; + Properties::const_iterator i = _properties.find(key); + if (i != _properties.end()) + return i->second; + else + return null_atom; +} + +} +} diff --git a/src/client/ClientObject.hpp b/src/client/ClientObject.hpp new file mode 100644 index 0000000..9b8403c --- /dev/null +++ b/src/client/ClientObject.hpp @@ -0,0 +1,69 @@ +/* This file is part of Machina. + * Copyright (C) 2010 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 Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Machina is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Machina. If not, see . + */ + +#ifndef MACHINA_CLIENTOBJECT_HPP +#define MACHINA_CLIENTOBJECT_HPP + +#include + +#include + +#include "raul/Atom.hpp" +#include "raul/SharedPtr.hpp" + +#include "machina/types.hpp" + +namespace Machina { +namespace Client { + +class ClientObject { +public: + ClientObject(uint64_t id); + ClientObject(const ClientObject& copy, uint64_t id); + + inline uint64_t id() const { return _id; } + + void set(URIInt key, const Raul::Atom& value); + const Raul::Atom& get(URIInt key) const; + + sigc::signal signal_property; + + class View { + public: + virtual ~View() {} + }; + + SharedPtr view() const { return _view; } + void set_view(SharedPtr view) { _view = view; } + +private: + uint64_t _id; + SharedPtr _view; + + typedef std::map Properties; + Properties _properties; +}; + +class ClientObjectKey : public ClientObject { +public: + ClientObjectKey(uint64_t id) : ClientObject(id) {} +}; + +} +} + +#endif // MACHINA_CLIENTOBJECT_HPP diff --git a/src/client/wscript b/src/client/wscript new file mode 100644 index 0000000..03082cc --- /dev/null +++ b/src/client/wscript @@ -0,0 +1,18 @@ +#!/usr/bin/env python +import autowaf + +def build(bld): + obj = bld(features = 'cxx cxxshlib') + obj.source = ''' + ClientModel.cpp + ClientObject.cpp + ''' + obj.export_includes = ['.'] + obj.includes = ['.', '..', '../..'] + obj.name = 'libmachina_client' + obj.target = 'machina_client' + obj.use = 'libmachina_engine' + autowaf.use_lib(bld, obj, 'RAUL') + + bld.add_post_fun(autowaf.run_ldconfig) + -- cgit v1.2.1