/* This file is part of Machina. * Copyright 2010-2011 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 { SPtr ClientModel::find(uint64_t id) { SPtr key(new ClientObjectKey(id)); Objects::iterator i = _objects.find(key); if (i != _objects.end()) { return *i; } else { return SPtr(); } } void ClientModel::new_object(SPtr object) { _objects.insert(object); signal_new_object.emit(object); } void ClientModel::erase_object(uint64_t id) { SPtr key(new ClientObjectKey(id)); Objects::iterator i = _objects.find(key); if (i == _objects.end()) { return; } signal_erase_object.emit(*i); (*i)->set_view(SPtr()); _objects.erase(i); } void ClientModel::property(uint64_t id, URIInt key, const Raul::Atom& value) { SPtr object = find(id); if (object) { object->set(key, value); } } } }