Last change
on this file since 25e17e9 was 5738177, checked in by Tillmann Crueger <crueger@…>, 15 years ago |
Added a generic Iterator that can be used to iterate only over certain parts of an internal data structure
|
-
Property mode
set to
100644
|
File size:
1.0 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 |
|
---|
16 | using namespace std;
|
---|
17 |
|
---|
18 | template<typename T>
|
---|
19 | AtomsCalculation<T>::AtomsCalculation(boost::function<T(atom*)> _op,std::string name,AtomDescriptor _descr) :
|
---|
20 | Calculation<std::vector<T> >(0,name,false),
|
---|
21 | descr(_descr),
|
---|
22 | op(_op)
|
---|
23 | {}
|
---|
24 |
|
---|
25 | template<typename T>
|
---|
26 | AtomsCalculation<T>::~AtomsCalculation(){
|
---|
27 | }
|
---|
28 |
|
---|
29 | template<typename T>
|
---|
30 | std::vector<T>* AtomsCalculation<T>::doCalc(){
|
---|
31 | World* world = World::getPointer();
|
---|
32 | int steps = world->numAtoms();
|
---|
33 | std::vector<T> *res = new std::vector<T>();
|
---|
34 | res->reserve(steps);
|
---|
35 | Process::setMaxSteps(steps);
|
---|
36 | Process::start();
|
---|
37 | for(World::AtomIterator iter=world->getAtomIter(descr);iter!=world->atomEnd();++iter){
|
---|
38 | Process::setCurrStep(iter.getCount());
|
---|
39 | res->push_back(op(*iter));
|
---|
40 | }
|
---|
41 | Process::stop();
|
---|
42 | return res;
|
---|
43 | }
|
---|
44 |
|
---|
45 |
|
---|
46 | #endif /* ATOMSCALCULATION_IMPL_HPP_ */
|
---|
Note:
See
TracBrowser
for help on using the repository browser.