29 #ifndef CDPL_CHEM_BASICMOLECULE_HPP
30 #define CDPL_CHEM_BASICMOLECULE_HPP
35 #include <boost/iterator/indirect_iterator.hpp>
66 typedef std::vector<AtomPtr> AtomList;
67 typedef std::vector<BondPtr> BondList;
76 typedef boost::indirect_iterator<AtomList::iterator, BasicAtom>
AtomIterator;
78 typedef boost::indirect_iterator<AtomList::const_iterator, const BasicAtom>
ConstAtomIterator;
80 typedef boost::indirect_iterator<BondList::iterator, BasicBond>
BondIterator;
82 typedef boost::indirect_iterator<BondList::const_iterator, const BasicBond>
ConstBondIterator;
316 using Molecule::operator=;
329 using Molecule::operator+=;
393 template <
typename T>
394 void doCopy(
const T& mol);
396 template <
typename T>
397 void doAppend(
const T& mol);
399 void clearAtomsAndBonds();
401 void renumberAtoms(std::size_t idx);
402 void renumberBonds(std::size_t idx);
407 static void destroyAtom(
BasicAtom* atom);
408 static void destroyBond(
BasicBond* bond);
Definition of class CDPL::Chem::BasicAtom.
Definition of class CDPL::Chem::BasicBond.
Definition of the preprocessor macro CDPL_CHEM_API.
#define CDPL_CHEM_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
Definition of class CDPL::Chem::Molecule.
Definition of class CDPL::Util::ObjectPool.
Abstract base class representing a chemical atom and its bonded neighborhood.
Definition: Atom.hpp:57
Concrete Chem::Atom implementation used as the atom type of Chem::BasicMolecule.
Definition: BasicAtom.hpp:58
Default implementation of the Chem::Bond interface.
Definition: BasicBond.hpp:52
Concrete Chem::Molecule implementation that owns Chem::BasicAtom and Chem::BasicBond instances.
Definition: BasicMolecule.hpp:60
void removeAtom(std::size_t idx)
Removes the atom at index idx (along with any incident bonds).
void orderAtoms(const AtomCompareFunction &func)
Reorders the atom list using the binary comparator func.
BasicBond & addBond(std::size_t atom1_idx, std::size_t atom2_idx)
Creates a new bond between the atoms at indices atom1_idx and atom2_idx and returns a reference to it...
std::size_t getBondIndex(const Bond &bond) const
Returns the index of bond bond in this molecule.
const BasicBond & getBond(std::size_t idx) const
Returns a const reference to the bond at index idx.
std::shared_ptr< BasicMolecule > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated BasicMolecule instances.
Definition: BasicMolecule.hpp:73
boost::indirect_iterator< AtomList::const_iterator, const BasicAtom > ConstAtomIterator
Constant random-access iterator over the atoms of the molecule.
Definition: BasicMolecule.hpp:78
void append(const MolecularGraph &molgraph)
Extends the current set of atoms and bonds by a copy of those in molgraph.
boost::indirect_iterator< BondList::iterator, BasicBond > BondIterator
Mutable random-access iterator over the bonds of the molecule.
Definition: BasicMolecule.hpp:80
bool containsBond(const Bond &bond) const
Tells whether bond is part of this molecule.
BondIterator removeBond(const BondIterator &it)
Removes the bond specified by the iterator it.
void clear()
Removes all atoms, bonds, and properties of the molecule.
void append(const Molecule &mol)
Extends the current set of atoms and bonds by a copy of those in mol.
BasicAtom & addAtom()
Creates and appends a new atom and returns a reference to it.
void removeBond(std::size_t idx)
Removes the bond at index idx.
ConstAtomIterator getAtomsEnd() const
Returns a constant iterator pointing to the end of the atoms.
const BasicAtom & getAtom(std::size_t idx) const
Returns a const reference to the atom at index idx.
void copy(const Molecule &mol)
Replaces the current set of atoms, bonds and properties by a copy of mol.
void orderBonds(const BondCompareFunction &func)
Reorders the bond list using the binary comparator func.
BasicMolecule(const Molecule &mol)
Constructs a copy of the Chem::Molecule instance mol.
ConstBondIterator getBondsEnd() const
Returns a constant iterator pointing to the end of the bonds.
std::size_t getNumAtoms() const
Returns the number of atoms in the molecule.
void copy(const MolecularGraph &molgraph)
Replaces the current set of atoms, bonds and properties by a copy of molgraph.
std::size_t getAtomIndex(const Atom &atom) const
Returns the index of atom atom in this molecule.
AtomIterator removeAtom(const AtomIterator &it)
Removes the atom specified by the iterator it.
BasicMolecule & operator=(const BasicMolecule &mol)
Replaces the current set of atoms, bonds and properties by a copy of the atoms, bonds and properties ...
std::size_t getNumBonds() const
Returns the number of bonds in the molecule.
void copy(const BasicMolecule &mol)
Replaces the current set of atoms, bonds and properties by a copy of the atoms, bonds and properties ...
BasicBond & getBond(std::size_t idx)
Returns a mutable reference to the bond at index idx.
boost::indirect_iterator< BondList::const_iterator, const BasicBond > ConstBondIterator
Constant random-access iterator over the bonds of the molecule.
Definition: BasicMolecule.hpp:82
void reserveMemoryForAtoms(std::size_t num_atoms)
Reserves storage for at least num_atoms atoms to avoid reallocations on subsequent additions.
BasicAtom & getAtom(std::size_t idx)
Returns a mutable reference to the atom at index idx.
boost::indirect_iterator< AtomList::iterator, BasicAtom > AtomIterator
Mutable random-access iterator over the atoms of the molecule.
Definition: BasicMolecule.hpp:76
BondIterator getBondsEnd()
Returns a mutable iterator pointing to the end of the bonds.
MolecularGraph::SharedPointer clone() const
Creates a copy of the molecular graph.
BasicMolecule()
Constructs an empty BasicMolecule instance.
BasicMolecule & operator+=(const BasicMolecule &mol)
Extends the current set of atoms and bonds by a copy of the atoms and bonds in the molecule mol.
ConstAtomIterator getAtomsBegin() const
Returns a constant iterator pointing to the beginning of the atoms.
BasicMolecule(const MolecularGraph &molgraph)
Constructs a BasicMolecule instance with copies of the atoms and bonds of the Chem::MolecularGraph in...
ConstBondIterator getBondsBegin() const
Returns a constant iterator pointing to the beginning of the bonds.
bool containsAtom(const Atom &atom) const
Tells whether atom is part of this molecule.
void reserveMemoryForBonds(std::size_t num_bonds)
Reserves storage for at least num_bonds bonds to avoid reallocations on subsequent additions.
AtomIterator getAtomsBegin()
Returns a mutable iterator pointing to the beginning of the atoms.
AtomIterator getAtomsEnd()
Returns a mutable iterator pointing to the end of the atoms.
~BasicMolecule()
Destructor.
BondIterator getBondsBegin()
Returns a mutable iterator pointing to the beginning of the bonds.
void remove(const MolecularGraph &molgraph)
Removes the atoms and bonds of molgraph from this molecule.
void append(const BasicMolecule &mol)
Extends the current set of atoms and bonds by a copy of the atoms and bonds in the molecule mol.
BasicMolecule(const BasicMolecule &mol)
Constructs a copy of the BasicMolecule instance mol.
Abstract base class representing a chemical bond between two Chem::Atom instances.
Definition: Bond.hpp:54
Abstract base class for representations of a chemical structure as a graph of bonded atoms.
Definition: MolecularGraph.hpp:57
std::shared_ptr< MolecularGraph > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated MolecularGraph instances.
Definition: MolecularGraph.hpp:63
Abstract base class representing a mutable molecular graph that owns its atoms and bonds.
Definition: Molecule.hpp:53
STL compatible random access iterator for container elements accessible by index.
Definition: IndexedElementIterator.hpp:125
std::shared_ptr< ObjectType > SharedObjectPointer
A smart pointer to a borrowed object that returns the object to the pool on destruction.
Definition: ObjectPool.hpp:71
constexpr unsigned int T
Specifies Hydrogen (Tritium).
Definition: AtomType.hpp:67
std::function< bool(const Atom &, const Atom &)> AtomCompareFunction
Generic wrapper class used to store a user-defined atom compare function.
Definition: AtomCompareFunction.hpp:41
std::function< bool(const Chem::Bond &, const Chem::Bond &)> BondCompareFunction
Generic wrapper class used to store a user-defined bond compare function.
Definition: BondCompareFunction.hpp:41
The namespace of the Chemical Data Processing Library.