LCOV - code coverage report
Current view: top level - coupling/interface/impl/SimpleMD - SimpleMDMoleculeIterator.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 17 0
Test Date: 2026-08-21 15:14:06 Functions: 0.0 % 6 0

            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 "coupling/interface/impl/SimpleMD/SimpleMDLinkedCellWrapper.h"
      11              : #include "simplemd/services/MoleculeService.h"
      12              : #include "simplemd/LinkedCell.h"
      13              : #include "simplemd/Molecule.h"
      14              : 
      15              : namespace coupling {
      16              : namespace interface {
      17              : 
      18              : /** iterates over molecules in a SimpleMD linked cell.
      19              :  *  @author Philipp Neumann
      20              :  */
      21              : class SimpleMDMoleculeIterator : public MoleculeIterator<SimpleMDLinkedCellWrapper, MD_DIM> {
      22              : public:
      23            0 :   SimpleMDMoleculeIterator(SimpleMDLinkedCellWrapper& cellWrapper, simplemd::services::MoleculeService& moleculeService)
      24            0 :       : coupling::interface::MoleculeIterator<SimpleMDLinkedCellWrapper, MD_DIM>(cellWrapper), _moleculeService(moleculeService), _moleculeIndex(0),
      25            0 :         _buffer(NULL) {}
      26            0 :   virtual ~SimpleMDMoleculeIterator() {}
      27              : 
      28              :   /** sets the iterator to the first element */
      29            0 :   void begin() { _moleculeIndex = 0; }
      30              : 
      31              :   /** returns false, if the iterator reached the end of the molecule list */
      32            0 :   bool continueIteration() const {
      33            0 :     auto cell = _moleculeService.getContainer()[_cell.getCellIndex()];
      34            0 :     return (_moleculeIndex < cell.numMolecules());
      35              :   }
      36              : 
      37              :   /** sets the iterator to the next molecule */
      38            0 :   void next() {
      39              :     // check if we need to update molecule information and reset flag in this case
      40            0 :     _moleculeIndex++;
      41            0 :   }
      42              : 
      43              :   /** returns a reference to the molecule that this iterator currently points to */
      44            0 :   coupling::interface::Molecule<MD_DIM>& get() {
      45            0 :     auto cell = _moleculeService.getContainer()[_cell.getCellIndex()];
      46            0 :     auto molecule = &_moleculeService.getContainer().getMoleculeAt(cell.getIndex(), _moleculeIndex);
      47            0 :     _buffer.setMolecule(molecule);
      48            0 :     return _buffer;
      49              :   }
      50              : 
      51            0 :   const coupling::interface::Molecule<MD_DIM>& getConst() { return get(); }
      52              : 
      53              : private:
      54              :   simplemd::services::MoleculeService& _moleculeService;
      55              :   size_t _moleculeIndex;
      56              :   coupling::interface::SimpleMDMolecule _buffer;
      57              : };
      58              : 
      59              : } // namespace interface
      60              : } // namespace coupling
      61              : 
      62              : #endif // _MOLECULARDYNAMIC_COUPLING_INTERFACE_SIMPLEMDMOLECULEITERATOR_CPP_
        

Generated by: LCOV version 2.0-1