/* * Project: MoleCuilder * Description: creates and alters molecular systems * Copyright (C) 2010 University of Bonn. All rights reserved. * Please see the LICENSE file or "Copyright notice" in builder.cpp for details. */ /* * AtomSelectionDescriptor.cpp * * Created on: Jul 16, 2010 * Author: crueger */ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include "CodePatterns/MemDebug.hpp" #include "Descriptors/AtomSelectionDescriptor.hpp" #include "Descriptors/AtomSelectionDescriptor_impl.hpp" #include "Helpers/helpers.hpp" AtomSelectionDescriptor_impl::AtomSelectionDescriptor_impl(){} AtomSelectionDescriptor_impl::~AtomSelectionDescriptor_impl(){} bool AtomSelectionDescriptor_impl::predicate(std::pair atom){ return getSelectedAtoms().count(atom.first); } atom* AtomSelectionDescriptor_impl::find(){ World::AtomSet &set = getSelectedAtoms(); World::AtomSet::internal_iterator begin = set.begin_internal(); return (begin!=set.end_internal())?(begin->second):0; } std::vector AtomSelectionDescriptor_impl::findAll(){ std::vector res; World::AtomSet &set = getSelectedAtoms(); transform(set.begin_internal(), set.end_internal(), back_inserter(res), _take::get); return res; } World::AtomSet& AtomSelectionDescriptor_impl::getSelectedAtoms(){ return World::getInstance().selectedAtoms; } AtomDescriptor AtomsBySelection(){ return AtomDescriptor(AtomDescriptor::impl_ptr(new AtomSelectionDescriptor_impl())); }