/*
* Project: MoleCuilder
* Description: creates and alters molecular systems
* Copyright (C) 2010-2012 University of Bonn. All rights reserved.
*
*
* This file is part of MoleCuilder.
*
* MoleCuilder 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 2 of the License, or
* (at your option) any later version.
*
* MoleCuilder 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 MoleCuilder. If not, see .
*/
/*
* MoleculeSelectionDescriptor.cpp
*
* Created on: Jul 16, 2010
* Author: crueger
*/
// include config.h
#ifdef HAVE_CONFIG_H
#include
#endif
#include "CodePatterns/MemDebug.hpp"
#include "Descriptors/MoleculeSelectionDescriptor.hpp"
#include "Descriptors/MoleculeSelectionDescriptor_impl.hpp"
#include "Helpers/helpers.hpp"
MoleculeSelectionDescriptor_impl::MoleculeSelectionDescriptor_impl(){}
MoleculeSelectionDescriptor_impl::~MoleculeSelectionDescriptor_impl(){}
bool MoleculeSelectionDescriptor_impl::predicate(const std::pair molecule) const{
return getSelectedMolecules().count(molecule.first);
}
molecule* MoleculeSelectionDescriptor_impl::find(){
World::MoleculeSet &set = getSelectedMolecules();
World::MoleculeSet::internal_iterator begin = set.begin_internal();
return (begin!=set.end_internal())?(begin->second):0;
}
const molecule* MoleculeSelectionDescriptor_impl::find() const {
const World::MoleculeSet &set = getSelectedMolecules();
World::MoleculeSet::const_iterator begin = set.begin();
return (begin!=set.end())?(begin->second):0;
}
std::vector MoleculeSelectionDescriptor_impl::findAll(){
std::vector res;
World::MoleculeSet &set = getSelectedMolecules();
transform(set.begin_internal(),
set.end_internal(),
back_inserter(res),
_take::get);
return res;
}
std::vector MoleculeSelectionDescriptor_impl::findAll() const {
std::vector res;
const World::MoleculeSet &set = getSelectedMolecules();
transform(set.begin(),
set.end(),
back_inserter(res),
_take::get);
return res;
}
World::MoleculeSet& MoleculeSelectionDescriptor_impl::getSelectedMolecules(){
return World::getInstance().selectedMolecules;
}
const World::MoleculeSet& MoleculeSelectionDescriptor_impl::getSelectedMolecules() const{
return World::getInstance().selectedMolecules;
}
MoleculeDescriptor MoleculesBySelection(){
return MoleculeDescriptor(MoleculeDescriptor::impl_ptr(new MoleculeSelectionDescriptor_impl()));
}