/* 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); } } }