source: molecuilder/src/Descriptors/AtomDescriptor.cpp@ 86b917

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

Added descriptors that allow multiple kinds of access to atoms

  • Property mode set to 100644
File size: 999 bytes
Line 
1/*
2 * AtomDescriptor.cpp
3 *
4 * Created on: Feb 5, 2010
5 * Author: crueger
6 */
7
8#include "AtomDescriptor.hpp"
9
10#include "World.hpp"
11
12#include <boost/bind.hpp>
13
14using namespace std;
15
16typedef map<int,atom*> atoms_t;
17typedef atoms_t::iterator atoms_iter_t;
18
19AtomDescriptor::AtomDescriptor()
20{
21}
22
23AtomDescriptor::~AtomDescriptor()
24{
25}
26
27
28atoms_t& AtomDescriptor::getAtoms(){
29 return World::get()->atoms;
30}
31
32AtomPredicateDescriptor::AtomPredicateDescriptor()
33{
34}
35
36AtomPredicateDescriptor::~AtomPredicateDescriptor()
37{
38}
39
40atom* AtomPredicateDescriptor::find() {
41 atoms_t atoms = getAtoms();
42 atoms_iter_t res = find_if(atoms.begin(),atoms.end(),boost::bind(&AtomPredicateDescriptor::predicate,this,_1));
43 return (res!=atoms.end())?((*res).second):0;
44}
45
46vector<atom*> AtomPredicateDescriptor::findAll() {
47 vector<atom*> res;
48 atoms_t atoms = getAtoms();
49 atoms_iter_t iter;
50 for(iter=atoms.begin();iter!=atoms.end();++iter) {
51 if(predicate(*iter))
52 res.push_back((*iter).second);
53 }
54}
Note: See TracBrowser for help on using the repository browser.