source: molecuilder/src/Descriptors/AtomIdDescriptor.cpp@ 8d9d38

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

Added Descriptor that allows querying of atoms by their type

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