OBResidueAtomIter Class Reference

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

#include <obiter.h>

List of all members.

Public Member Functions

 OBResidueAtomIter ()
 OBResidueAtomIter (OBResidue *res)
 OBResidueAtomIter (OBResidue &res)
 OBResidueAtomIter (const OBResidueAtomIter &ri)
OBResidueAtomIteroperator= (const OBResidueAtomIter &ri)
 operator bool () const
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) or the OBResidue::BeginAtom() and OBResidue::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_RESIDUE(a,r)     for( OBResidueAtomIter     a(r); a; a++ )

Here is an example:

   #include "obiter.h"
   #include "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  ) 


Member Function Documentation

OBResidueAtomIter & operator= ( const OBResidueAtomIter ri  ) 

operator bool (  )  const [inline]

OBResidueAtomIter operator++ ( int   ) 

OBAtom* operator-> (  )  const [inline]

OBAtom& operator * (  )  const [inline]


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