OBAtomBondIter Class Reference

Iterate over all bonds on an OBAtom. More...

#include <openbabel/obiter.h>

List of all members.

Public Member Functions

 OBAtomBondIter ()
 OBAtomBondIter (OBAtom *atm)
 OBAtomBondIter (OBAtom &atm)
 OBAtomBondIter (const OBAtomBondIter &bi)
 ~OBAtomBondIter ()
OBAtomBondIteroperator= (const OBAtomBondIter &bi)
 operator bool () const
OBAtomBondIteroperator++ ()
OBAtomBondIter operator++ (int)
OBBondoperator-> () const
OBBondoperator* () const

Detailed Description

Iterate over all bonds on an OBAtom.

To facilitate iteration through all bonds on an atom, without resorting to bond 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_BONDS_OF_ATOM(b,p)     for( OBAtomBondIter     b(p); b; ++b )

Here is an example:

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

      OBAtom atom;
      unsigned int tripleBondCount;
      FOR_BONDS_OF_ATOM(b, atom)
      {
         // The variable b behaves like OBBond* when used with -> and * but
         // but needs to be explicitly converted when appearing as a parameter
         // in a function call - use &*b
         if (b->GetBO() == 3)
            tripleBondCount++;
      }

Constructor & Destructor Documentation

OBAtomBondIter (  ) [inline]
OBAtomBondIter ( OBAtom atm )
OBAtomBondIter ( OBAtom atm )
OBAtomBondIter ( const OBAtomBondIter bi )
~OBAtomBondIter (  ) [inline]

Member Function Documentation

OBAtomBondIter & operator= ( const OBAtomBondIter bi )
operator bool (  ) const [inline]
Returns:
Whether the iterator can still advance (i.e., visit more bonds)
OBAtomBondIter & operator++ (  )

Preincrement -- advance to the next bond and return.

Referenced by OBAtomBondIter::operator++().

OBAtomBondIter operator++ ( int   )

Postincrement -- return the current state and advance to the next bond.

OBBond* operator-> (  ) const [inline]
Returns:
a pointer to the current bond
OBBond& operator* (  ) const [inline]
Returns:
a reference to the current bond

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines