Line data Source code
1 : // Copyright (C) 2015 Technische Universitaet Muenchen 2 : // This file is part of the Mamico project. For conditions of distribution 3 : // and use, please see the copyright notice in Mamico's main folder, or at 4 : // www5.in.tum.de/mamico 5 : #ifndef _MOLECULARDYNAMIC_COUPLING_INTERFACE_SIMPLEMDMOLECULEITERATOR_CPP_ 6 : #define _MOLECULARDYNAMIC_COUPLING_INTERFACE_SIMPLEMDMOLECULEITERATOR_CPP_ 7 : 8 : #include "coupling/interface/MoleculeIterator.h" 9 : #include "coupling/interface/impl/SimpleMD/SimpleMDMolecule.h" 10 : #include "simplemd/LinkedCell.h" 11 : #include "simplemd/Molecule.h" 12 : 13 : namespace coupling { 14 : namespace interface { 15 : 16 : /** iterates over molecules in a SimpleMD linked cell. 17 : * @author Philipp Neumann 18 : */ 19 : class SimpleMDMoleculeIterator : public MoleculeIterator<simplemd::LinkedCell, MD_DIM> { 20 : public: 21 0 : SimpleMDMoleculeIterator(simplemd::LinkedCell& cell) : coupling::interface::MoleculeIterator<simplemd::LinkedCell, MD_DIM>(cell), _buffer(NULL) {} 22 0 : virtual ~SimpleMDMoleculeIterator() {} 23 : 24 : /** sets the iterator to the first element */ 25 0 : void begin() { _it = _cell.begin(); } 26 : 27 : /** returns false, if the iterator reached the end of the molecule list */ 28 0 : bool continueIteration() const { return (_it != _cell.end()); } 29 : 30 : /** sets the iterator to the next molecule */ 31 0 : void next() { 32 : // check if we need to update molecule information and reset flag in this case 33 0 : _it++; 34 0 : } 35 : 36 : /** returns a reference to the molecule that this iterator currently points to */ 37 0 : coupling::interface::Molecule<MD_DIM>& get() { 38 0 : _buffer.setMolecule(*_it); 39 0 : return _buffer; 40 : } 41 : 42 0 : const coupling::interface::Molecule<MD_DIM>& getConst() { 43 0 : _buffer.setMolecule(*_it); 44 0 : return _buffer; 45 : } 46 : 47 : private: 48 : std::list<simplemd::Molecule*>::iterator _it; 49 : coupling::interface::SimpleMDMolecule _buffer; 50 : }; 51 : 52 : } // namespace interface 53 : } // namespace coupling 54 : 55 : #endif // _MOLECULARDYNAMIC_COUPLING_INTERFACE_SIMPLEMDMOLECULEITERATOR_CPP_