|
Last change
on this file since f058ef 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
|
| Rev | Line | |
|---|
| [f058ef] | 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 |
|
|---|
| 13 | using namespace std;
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 | MoleculeIdDescriptor_impl::MoleculeIdDescriptor_impl(moleculeId_t _id) :
|
|---|
| 17 | id(_id)
|
|---|
| 18 | {}
|
|---|
| 19 |
|
|---|
| 20 | MoleculeIdDescriptor_impl::~MoleculeIdDescriptor_impl()
|
|---|
| 21 | {}
|
|---|
| 22 |
|
|---|
| 23 | bool MoleculeIdDescriptor_impl::predicate(std::pair<moleculeId_t,molecule*> molecule) {
|
|---|
| 24 | return molecule.first==id;
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
| 27 | MoleculeDescriptor MoleculeById(moleculeId_t id){
|
|---|
| 28 | return MoleculeDescriptor(MoleculeDescriptor::impl_ptr(new MoleculeIdDescriptor_impl(id)));
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | molecule *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 |
|
|---|
| 37 | vector<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.