source: molecuilder/src/Descriptors/AtomIdDescriptor.cpp@ 323177

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

Rebuilt AtomDescriptors using PIMPL-Idiom and added unittest for descriptors

  • Property mode set to 100644
File size: 1011 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.second->getId()==id;
25}
26
27AtomDescriptor AtomById(int id){
28 return AtomDescriptor(AtomDescriptor::impl_ptr(new AtomIdDescriptor_impl(id)));
29}
30
31#if 0
32
33// so far the lookuptable for Atoms-by-id does not work, since atoms don't get an ID upon creation.
34// instead of this we rely on walking through all atoms.
35
36atom *AtomIdDescriptor::find(){
37 map<int,atom*> atoms = getAtoms();
38 map<int,atom*>::iterator res = atoms.find(id);
39 return (res!=atoms.end())?((*res).second):0;
40}
41
42vector<atom*> AtomIdDescriptor::findAll(){
43 atom *res = find();
44 return (res)?(vector<atom*>(1,res)):(vector<atom*>());
45}
46
47#endif
Note: See TracBrowser for help on using the repository browser.