Loading...
Searching...
No Matches
OBResidueAtomIter Class Reference

`#include <openbabel/obiter.h>`

## Public Member Functions

| OBResidueAtomIter ()
| OBResidueAtomIter (OBResidue *res)
| OBResidueAtomIter (OBResidue &res)
| OBResidueAtomIter (const OBResidueAtomIter &ri)
| ~OBResidueAtomIter ()
OBResidueAtomIter & | operator= (const OBResidueAtomIter &ri)
| operator bool () const
OBResidueAtomIter & | operator++ ()
OBResidueAtomIter | operator++ (int)
OBAtom * | operator-> () const
OBAtom & | operator* () 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 )
OpenBabel::OBResidueAtomIter::OBResidueAtomIter
OBResidueAtomIter()
Definition obiter.h:274
FOR_ATOMS_OF_RESIDUE
#define FOR_ATOMS_OF_RESIDUE(a, r)
Definition obiter.h:403

Here is an example:

#include <openbabel/obiter.h>
#include <openbabel/mol.h>
OpenBabel::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();
}
}
}
OpenBabel::OBMol
Molecule Class.
Definition mol.h:121
mol.h
Handle molecules. Declarations of OBMol, OBAtom, OBBond, OBResidue. (the main header for Open Babel).
obiter.h
STL-style iterators for Open Babel.
FOR_RESIDUES_OF_MOL
#define FOR_RESIDUES_OF_MOL(r, m)
Definition obiter.h:402

## Constructor & Destructor Documentation

## OBResidueAtomIter() [1/4]

OBResidueAtomIter | ( |  | ) |

inline

Referenced by OBResidueAtomIter(), operator++(), operator++(), and operator=().

## OBResidueAtomIter() [2/4]

OBResidueAtomIter | ( | OBResidue * | res | ) |

## OBResidueAtomIter() [3/4]

OBResidueAtomIter | ( | OBResidue & | res | ) |

## OBResidueAtomIter() [4/4]

OBResidueAtomIter | ( | const OBResidueAtomIter & | ri | ) |

## ~OBResidueAtomIter()

~OBResidueAtomIter | ( |  | ) |

inline

## Member Function Documentation

## operator=()

OBResidueAtomIter & operator= | ( | const OBResidueAtomIter & | ri | ) |

## operator bool()

operator bool | ( |  | ) | const

inline

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

## operator++() [1/2]

OBResidueAtomIter & operator++ | ( |  | ) |

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

Referenced by operator++().

## operator++() [2/2]

OBResidueAtomIter operator++ | ( | int |  | ) |

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

## operator->()

OBAtom * operator-> | ( |  | ) | const

inline

Returns
  a pointer to the current atom

## operator*()

OBAtom & operator* | ( |  | ) | const

inline

Returns
  a reference to the current atom

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

- obiter.h
- obiter.cpp