/* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* * Copyright (c) 2008, 2010, 2011 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General * Public License version 2, as published by the Free Software Foundation. * * Paludis 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 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple * Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include #include #include using namespace paludis; GeneratorHandler::~GeneratorHandler() { } std::shared_ptr AllGeneratorHandlerBase::repositories( const Environment * const env, const RepositoryContentMayExcludes &) const { using namespace std::placeholders; std::shared_ptr result(std::make_shared()); std::transform(env->begin_repositories(), env->end_repositories(), result->inserter(), std::bind(&Repository::name, _1)); return result; } std::shared_ptr AllGeneratorHandlerBase::categories( const Environment * const env, const std::shared_ptr & repos, const RepositoryContentMayExcludes & may_exclude) const { std::shared_ptr result(std::make_shared()); for (RepositoryNameSet::ConstIterator r(repos->begin()), r_end(repos->end()) ; r != r_end ; ++r) { std::shared_ptr cats(env->fetch_repository(*r)->category_names(may_exclude)); std::copy(cats->begin(), cats->end(), result->inserter()); } return result; } std::shared_ptr AllGeneratorHandlerBase::packages( const Environment * const env, const std::shared_ptr & repos, const std::shared_ptr & cats, const RepositoryContentMayExcludes & may_exclude) const { std::shared_ptr result(std::make_shared()); for (RepositoryNameSet::ConstIterator r(repos->begin()), r_end(repos->end()) ; r != r_end ; ++r) { for (CategoryNamePartSet::ConstIterator c(cats->begin()), c_end(cats->end()) ; c != c_end ; ++c) { std::shared_ptr pkgs( env->fetch_repository(*r)->package_names(*c, may_exclude)); std::copy(pkgs->begin(), pkgs->end(), result->inserter()); } } return result; } std::shared_ptr AllGeneratorHandlerBase::ids( const Environment * const env, const std::shared_ptr & repos, const std::shared_ptr & qpns, const RepositoryContentMayExcludes & may_exclude) const { std::shared_ptr result(std::make_shared()); for (RepositoryNameSet::ConstIterator r(repos->begin()), r_end(repos->end()) ; r != r_end ; ++r) { for (QualifiedPackageNameSet::ConstIterator q(qpns->begin()), q_end(qpns->end()) ; q != q_end ; ++q) { std::shared_ptr i(env->fetch_repository(*r)->package_ids(*q, may_exclude)); std::copy(i->begin(), i->end(), result->inserter()); } } return result; }