source: molecuilder/src/Descriptors/MoleculeIdDescriptor.cpp@ b918031

Last change on this file since b918031 was f058ef, checked in by Tillmann Crueger <crueger@…>, 16 years ago

Added methods to query Molecules by ID

  • Property mode set to 100644
File size: 985 bytes
Line 
1/*
2 * MoleculeIdDescriptor.cpp
3 *
4 * Created on: Feb 5, 2010
5 * Author: crueger
6 */
7
8#include "MoleculeIdDescriptor.hpp"
9#include "MoleculeIdDescriptor_impl.hpp"
10
11#include "molecule.hpp"
12
13using namespace std;
14
15
16MoleculeIdDescriptor_impl::MoleculeIdDescriptor_impl(moleculeId_t _id) :
17 id(_id)
18{}
19
20MoleculeIdDescriptor_impl::~MoleculeIdDescriptor_impl()
21{}
22
23bool MoleculeIdDescriptor_impl::predicate(std::pair<moleculeId_t,molecule*> molecule) {
24 return molecule.first==id;
25}
26
27MoleculeDescriptor MoleculeById(moleculeId_t id){
28 return MoleculeDescriptor(MoleculeDescriptor::impl_ptr(new MoleculeIdDescriptor_impl(id)));
29}
30
31molecule *MoleculeIdDescriptor_impl::find(){
32 World::MoleculeSet molecules = getMolecules();
33 World::MoleculeSet::iterator res = molecules.find(id);
34 return (res!=molecules.end())?((*res).second):0;
35}
36
37vector<molecule*> MoleculeIdDescriptor_impl::findAll(){
38 molecule *res = find();
39 return (res)?(vector<molecule*>(1,res)):(vector<molecule*>());
40}
Note: See TracBrowser for help on using the repository browser.