OBMolAtomIter Class Reference

Iterate over all atoms in an OBMol. More...

#include <obiter.h>

List of all members.

Public Member Functions

 OBMolAtomIter ()
 OBMolAtomIter (OBMol *mol)
 OBMolAtomIter (OBMol &mol)
 OBMolAtomIter (const OBMolAtomIter &ai)
OBMolAtomIteroperator= (const OBMolAtomIter &ai)
 operator bool () const
OBMolAtomIter operator++ (int)
OBAtomoperator-> () const
OBAtomoperator * () const


Detailed Description

Iterate over all atoms in an OBMol.

To facilitate iteration through all atoms in a molecule, without resorting to atom indexes (which may change in the future) or the OBMol::BeginAtom() and OBMol::NextAtom() methods which may be deprecated in the future.

This has been made significantly easier by a series of macros in the obiter.h header file:

    \#define FOR_ATOMS_OF_MOL(a,m)     for( OBMolAtomIter     a(m); a; a++ )

Here is an example:

     #include "obiter.h"
   #include "mol.h"

   OBMol mol;
   double exactMass = 0.0f;
   FOR_ATOMS_OF_MOL(a, mol)
   {
  // The variable a behaves like OBAtom* when used with -> and * but
  // but needs to be explicitly converted when appearing as a parameter
  // in a function call - use &*a
  
       exactMass +=  a->GetExactMass();
   }


Constructor & Destructor Documentation

OBMolAtomIter (  )  [inline]

OBMolAtomIter ( OBMol mol  ) 

OBMolAtomIter ( OBMol mol  ) 

OBMolAtomIter ( const OBMolAtomIter ai  ) 


Member Function Documentation

OBMolAtomIter & operator= ( const OBMolAtomIter ai  ) 

operator bool (  )  const [inline]

OBMolAtomIter operator++ ( int   ) 

OBAtom* operator-> (  )  const [inline]

OBAtom& operator * (  )  const [inline]


The documentation for this class was generated from the following files: