/* * 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. */ /* * MoleculeNameDescriptor.cpp * * Created on: Jun 9, 2010 * Author: heber */ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include "CodePatterns/MemDebug.hpp" #include "MoleculeNameDescriptor.hpp" #include "MoleculeNameDescriptor_impl.hpp" #include "molecule.hpp" using namespace std; MoleculeNameDescriptor_impl::MoleculeNameDescriptor_impl(std::string _name) : name(_name) {} MoleculeNameDescriptor_impl::~MoleculeNameDescriptor_impl() {} bool MoleculeNameDescriptor_impl::predicate(std::pair molecule) { return molecule.second->name==name; } MoleculeDescriptor MoleculeByName(std::string name){ return MoleculeDescriptor(MoleculeDescriptor::impl_ptr(new MoleculeNameDescriptor_impl(name))); } molecule *MoleculeNameDescriptor_impl::find(){ World::MoleculeSet &molecules = getMolecules(); World::MoleculeSet::iterator res = molecules.begin(); for (; res != molecules.end(); res++) if (res->second->name == name) break; return (res!=molecules.end())?((*res).second):0; } vector MoleculeNameDescriptor_impl::findAll(){ vector foundMolecules; World::MoleculeSet &molecules = getMolecules(); World::MoleculeSet::iterator res = molecules.begin(); for (; res != molecules.end(); res++) if (res->second->name == name) foundMolecules.push_back(res->second); return foundMolecules; }