OBMolAtomIter Class Reference

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

#include <openbabel/obiter.h>

List of all members.

Public Member Functions

 OBMolAtomIter ()
 OBMolAtomIter (OBMol *mol)
 OBMolAtomIter (OBMol &mol)
 OBMolAtomIter (const OBMolAtomIter &ai)
 ~OBMolAtomIter ()
OBMolAtomIteroperator= (const OBMolAtomIter &ai)
 operator bool () const
OBMolAtomIteroperator++ ()
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 will change in the future), a variety of iterator methods are provided.

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 <openbabel/obiter.h>
      #include <openbabel/mol.h>

      OBMol mol;
      double exactMass = 0.0;
      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  ) 

~OBMolAtomIter (  )  [inline]


Member Function Documentation

OBMolAtomIter & operator= ( const OBMolAtomIter ai  ) 

operator bool (  )  const [inline]

Returns:
Whether the iterator can still advance (i.e., visit more atoms)

OBMolAtomIter & operator++ (  ) 

Preincrement iterator -- advance to next atom and return.

Referenced by OBMolAtomIter::operator++().

OBMolAtomIter operator++ ( int   ) 

Postincrement iterator -- return the current atom and advance.

OBAtom* operator-> (  )  const [inline]

Returns:
a pointer to the current atom

OBAtom& operator* (  )  const [inline]

Returns:
a reference to the current atom


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