source: molecuilder/src/Actions/AtomsCalculation_impl.hpp@ 01d28a

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

Added templates that allow arbitrary calculations on atoms to be mapped to sets of Atoms

  • Property mode set to 100644
File size: 1.1 KB
Line 
1/*
2 * AtomsCalculation_impl.hpp
3 *
4 * Created on: Feb 19, 2010
5 * Author: crueger
6 */
7
8#ifndef ATOMSCALCULATION_IMPL_HPP_
9#define ATOMSCALCULATION_IMPL_HPP_
10
11#include "Actions/AtomsCalculation.hpp"
12#include "Actions/Calculation_impl.hpp"
13
14#include <iostream>
15
16using namespace std;
17
18template<typename T>
19AtomsCalculation<T>::AtomsCalculation(boost::function<T(atom*)> _op,std::string name,AtomDescriptor _descr) :
20 Calculation<std::vector<T> >(0,name,false),
21 op(_op),
22 descr(_descr)
23{}
24
25template<typename T>
26AtomsCalculation<T>::~AtomsCalculation(){
27}
28
29template<typename T>
30std::vector<T>* AtomsCalculation<T>::doCalc(){
31 World* world = World::get();
32 int steps = world->numAtoms();
33 int count = 0;
34 std::vector<T> *res = new std::vector<T>();
35 res->reserve(steps);
36 Process::setMaxSteps(steps);
37 Process::start();
38 World::AtomIterator iter;
39 for(iter=world->getAtomIter(descr);iter!=world->atomEnd();++iter){
40 Process::setCurrStep(iter.getCount());
41 res->push_back(op(*iter));
42 }
43 Process::stop();
44 return res;
45}
46
47
48#endif /* ATOMSCALCULATION_IMPL_HPP_ */
Note: See TracBrowser for help on using the repository browser.