OBResidueAtomIter Class Reference

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

#include <openbabel/obiter.h>

List of all members.

Public Member Functions

 OBResidueAtomIter ()
 OBResidueAtomIter (OBResidue *res)
 OBResidueAtomIter (OBResidue &res)
 OBResidueAtomIter (const OBResidueAtomIter &ri)
 ~OBResidueAtomIter ()
OBResidueAtomIteroperator= (const OBResidueAtomIter &ri)
 operator bool () const
OBResidueAtomIteroperator++ ()
OBResidueAtomIter operator++ (int)
OBAtomoperator-> () const
OBAtomoperator* () const


Detailed Description

Iterate over all atoms in an OBResidue.

To facilitate iteration through all atoms in a residue, without resorting to atom indexes (which may change in the future) a variety of iterator classes and methods are provided.

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

      \#define FOR_ATOMS_OF_RESIDUE(a,r)     for( OBResidueAtomIter     a(r); a; ++a )

Here is an example:

      #include <openbabel/obiter.h>
      #include <openbabel/mol.h>

      OBMol mol;
      double residueMass = 0.0;
      FOR_RESIDUES_OF_MOL(r, mol)
      {
         // The variable r behaves like OBResidue* when used with -> and * but
         // but needs to be explicitly converted when appearing as a parameter
         // in a function call - use &*r

         if (r->GetName() == resname && r->GetNum() == rnum) 
         {
            FOR_ATOMS_OF_RESIDUE(a, &*r)
            {
               residueMass += a->GetMass();
            }
         }
      }

Constructor & Destructor Documentation

OBResidueAtomIter (  )  [inline]

OBResidueAtomIter ( OBResidue res  ) 

OBResidueAtomIter ( OBResidue res  ) 

OBResidueAtomIter ( const OBResidueAtomIter ri  ) 

~OBResidueAtomIter (  )  [inline]


Member Function Documentation

OBResidueAtomIter & operator= ( const OBResidueAtomIter ri  ) 

operator bool (  )  const [inline]

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

OBResidueAtomIter & operator++ (  ) 

Preincrement -- advance to the next atom (if any) and return.

Referenced by OBResidueAtomIter::operator++().

OBResidueAtomIter operator++ ( int   ) 

Postincrement -- return the current state and advance to the next atom (if any).

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: