BondIterators.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (C) 2002-2006 Greg Landrum and Rational Discovery LLC
00003 //
00004 //   @@ All Rights Reserved @@
00005 //  This file is part of the RDKit.
00006 //  The contents are covered by the terms of the BSD license
00007 //  which is included in the file license.txt, found at the root
00008 //  of the RDKit source tree.
00009 //
00010 /*! \file BondIterators.h
00011 
00012   \brief various tools for iterating over a molecule's Bonds
00013 
00014    <b>WARNING:</b> If you go changing the molecule underneath one of
00015    these iterators you will be sad...
00016 */  
00017 #ifndef _RD_BOND_ITERATORS_H
00018 #define _RD_BOND_ITERATORS_H
00019 
00020 #include "ROMol.h"
00021 
00022 namespace RDKit{
00023 
00024   //! \brief iterator for a molecule's bonds, currently BiDirectional,
00025   //! but it theoretically ought to be RandomAccess.
00026   class BondIterator_ {
00027     //FIX: I'm not pleased with the lack of internal testing code
00028     //  (PREs and the like) in here
00029   public:
00030     BondIterator_() : _mol(NULL) {}; 
00031     BondIterator_(ROMol *mol);
00032     BondIterator_(ROMol *mol,ROMol::EDGE_ITER pos);
00033     BondIterator_(const BondIterator_ &other);
00034     BondIterator_ &operator=(const BondIterator_ &other);
00035     bool operator==(const BondIterator_ &other);
00036     bool operator!=(const BondIterator_ &other);
00037     Bond *operator*();
00038     // pre-increment
00039     BondIterator_ &operator++();
00040     BondIterator_ operator++(int);
00041     // pre-decrement
00042     BondIterator_ &operator--();
00043     BondIterator_ operator--(int);
00044   private:
00045     ROMol::EDGE_ITER _beg,_end,_pos;
00046     ROMol *_mol;
00047   };
00048   //! \brief const iterator for a molecule's bonds, currently BiDirectional,
00049   //! but it theoretically ought to be RandomAccess.
00050   class ConstBondIterator_ {
00051   public:
00052     ConstBondIterator_() : _mol(NULL) {}; 
00053     ConstBondIterator_(ROMol const *mol);
00054     ConstBondIterator_(ROMol const *mol,ROMol::EDGE_ITER pos);
00055     ConstBondIterator_(const ConstBondIterator_ &other);
00056     ConstBondIterator_ &operator=(const ConstBondIterator_ &other);
00057     bool operator==(const ConstBondIterator_ &other);
00058     bool operator!=(const ConstBondIterator_ &other);
00059     Bond const *operator*();
00060     // pre-increment
00061     ConstBondIterator_ &operator++();
00062     ConstBondIterator_ operator++(int);
00063     // pre-decrement
00064     ConstBondIterator_ &operator--();
00065     ConstBondIterator_ operator--(int);
00066   private:
00067     ROMol::EDGE_ITER _beg,_end,_pos;
00068     ROMol const *_mol;
00069   };
00070 
00071 }  
00072 
00073 
00074 #endif