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 //
00006 /*! \file BondIterators.h
00007 
00008   \brief various tools for iterating over a molecule's Bonds
00009 
00010    <b>WARNING:</b> If you go changing the molecule underneath one of
00011    these iterators you will be sad...
00012 */  
00013 #ifndef _RD_BOND_ITERATORS_H
00014 #define _RD_BOND_ITERATORS_H
00015 
00016 #include "ROMol.h"
00017 
00018 namespace RDKit{
00019 
00020   //! \brief iterator for a molecule's bonds, currently BiDirectional,
00021   //! but it theoretically ought to be RandomAccess.
00022   class BondIterator_ {
00023     //FIX: I'm not pleased with the lack of internal testing code
00024     //  (PREs and the like) in here
00025   public:
00026     BondIterator_() : _mol(NULL) {}; 
00027     BondIterator_(ROMol *mol);
00028     BondIterator_(ROMol *mol,ROMol::EDGE_ITER pos);
00029     BondIterator_(const BondIterator_ &other);
00030     BondIterator_ &operator=(const BondIterator_ &other);
00031     bool operator==(const BondIterator_ &other);
00032     bool operator!=(const BondIterator_ &other);
00033     Bond *operator*();
00034     // pre-increment
00035     BondIterator_ &operator++();
00036     BondIterator_ operator++(int);
00037     // pre-decrement
00038     BondIterator_ &operator--();
00039     BondIterator_ operator--(int);
00040   private:
00041     ROMol::GRAPH_MOL_BOND_PMAP::type _pMap;
00042     ROMol::EDGE_ITER _beg,_end,_pos;
00043     ROMol *_mol;
00044   };
00045   //! \brief const iterator for a molecule's bonds, currently BiDirectional,
00046   //! but it theoretically ought to be RandomAccess.
00047   class ConstBondIterator_ {
00048   public:
00049     ConstBondIterator_() : _mol(NULL) {}; 
00050     ConstBondIterator_(ROMol const *mol);
00051     ConstBondIterator_(ROMol const *mol,ROMol::EDGE_ITER pos);
00052     ConstBondIterator_(const ConstBondIterator_ &other);
00053     ConstBondIterator_ &operator=(const ConstBondIterator_ &other);
00054     bool operator==(const ConstBondIterator_ &other);
00055     bool operator!=(const ConstBondIterator_ &other);
00056     Bond const *operator*();
00057     // pre-increment
00058     ConstBondIterator_ &operator++();
00059     ConstBondIterator_ operator++(int);
00060     // pre-decrement
00061     ConstBondIterator_ &operator--();
00062     ConstBondIterator_ operator--(int);
00063   private:
00064     ROMol::GRAPH_MOL_BOND_PMAP::const_type _pMap;
00065     ROMol::EDGE_ITER _beg,_end,_pos;
00066     ROMol const *_mol;
00067   };
00068 
00069 }  
00070 
00071 
00072 #endif

Generated on Sat May 24 08:36:32 2008 for RDCode by  doxygen 1.5.3