Chemical Data Processing Library C++ API - Version 1.0.0
Molecule.hpp
Go to the documentation of this file.
1 /*
2  * Molecule.hpp
3  *
4  * This file is part of the Chemical Data Processing Toolkit
5  *
6  * Copyright (C) 2003 Thomas Seidel <thomas.seidel@univie.ac.at>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; see the file COPYING. If not, write to
20  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23 
29 #ifndef CDPL_CHEM_MOLECULE_HPP
30 #define CDPL_CHEM_MOLECULE_HPP
31 
32 #include <memory>
33 
34 #include "CDPL/Chem/APIPrefix.hpp"
36 
37 
38 namespace CDPL
39 {
40 
41  namespace Chem
42  {
43 
48  {
49 
50  public:
54  typedef std::shared_ptr<Molecule> SharedPointer;
55 
60 
65 
70 
75 
81  virtual ~Molecule() {}
82 
85 
88 
92  virtual void clear() = 0;
93 
98  virtual std::size_t getNumAtoms() const = 0;
99 
104  virtual std::size_t getNumBonds() const = 0;
105 
112  virtual const Atom& getAtom(std::size_t idx) const = 0;
113 
120  virtual Atom& getAtom(std::size_t idx) = 0;
121 
129  virtual Atom& addAtom() = 0;
130 
140  virtual void removeAtom(std::size_t idx) = 0;
141 
154 
161  virtual const Bond& getBond(std::size_t idx) const = 0;
162 
169  virtual Bond& getBond(std::size_t idx) = 0;
170 
185  virtual Bond& addBond(std::size_t atom1_idx, std::size_t atom2_idx) = 0;
186 
192  virtual void removeBond(std::size_t idx) = 0;
193 
202 
208  virtual bool containsAtom(const Atom& atom) const = 0;
209 
215  virtual bool containsBond(const Bond& bond) const = 0;
216 
223  virtual std::size_t getAtomIndex(const Atom& atom) const = 0;
224 
231  virtual std::size_t getBondIndex(const Bond& bond) const = 0;
232 
238  virtual void copy(const Molecule& mol) = 0;
239 
245  virtual void copy(const MolecularGraph& molgraph) = 0;
246 
253  virtual void append(const Molecule& mol) = 0;
254 
261  virtual void append(const MolecularGraph& molgraph) = 0;
262 
268  virtual void remove(const MolecularGraph& molgraph) = 0;
269 
277  virtual void reserveMemoryForAtoms(std::size_t num_atoms) {}
278 
286  virtual void reserveMemoryForBonds(std::size_t num_bonds) {}
287 
297  Molecule& operator=(const Molecule& mol);
298 
308  Molecule& operator=(const MolecularGraph& molgraph);
309 
319  Molecule& operator+=(const Molecule& mol);
320 
330  Molecule& operator+=(const MolecularGraph& molgraph);
331 
340  Molecule& operator-=(const MolecularGraph& molgraph);
341  };
342  } // namespace Chem
343 } // namespace CDPL
344 
345 #endif // CDPL_CHEM_MOLECULE_HPP
CDPL::Chem::Molecule::clear
virtual void clear()=0
Removes all atoms and bonds and clears all properties of the molecule.
CDPL::Chem::Molecule::getAtom
virtual Atom & getAtom(std::size_t idx)=0
Returns a non-const reference to the atom at index idx.
APIPrefix.hpp
Definition of the preprocessor macro CDPL_CHEM_API.
CDPL_CHEM_API
#define CDPL_CHEM_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
CDPL::Chem::Bond
Bond.
Definition: Bond.hpp:50
CDPL::Chem::Molecule::getBondIndex
virtual std::size_t getBondIndex(const Bond &bond) const =0
Returns the index of the specified bond.
CDPL::Chem::Molecule::getBond
virtual const Bond & getBond(std::size_t idx) const =0
Returns a const reference to the bond at index idx.
CDPL::Chem::BondContainer::getBondsBegin
ConstBondIterator getBondsBegin() const
Returns a constant iterator pointing to the beginning of the stored const Chem::Bond objects.
CDPL::Chem::Molecule::~Molecule
virtual ~Molecule()
Virtual destructor.
Definition: Molecule.hpp:81
CDPL::Chem::BondContainer::getBondsEnd
ConstBondIterator getBondsEnd() const
Returns a constant iterator pointing to the end of the stored const Chem::Bond objects.
CDPL::Util::IndexedElementIterator
A STL compatible random access iterator for container elements accessible by index.
Definition: IndexedElementIterator.hpp:125
CDPL::Chem::Atom
Atom.
Definition: Atom.hpp:52
CDPL::Chem::Molecule::reserveMemoryForAtoms
virtual void reserveMemoryForAtoms(std::size_t num_atoms)
Reserves memory for num_atoms atoms.
Definition: Molecule.hpp:277
CDPL::Chem::Molecule::getNumAtoms
virtual std::size_t getNumAtoms() const =0
Returns the number of explicit atoms.
CDPL::Chem::Molecule::SharedPointer
std::shared_ptr< Molecule > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated Molecule instances.
Definition: Molecule.hpp:54
CDPL::Chem::Molecule::copy
virtual void copy(const MolecularGraph &molgraph)=0
Replaces the current set of atoms, bonds and properties by a copy of the atoms, bonds and properties ...
CDPL::Chem::Molecule::containsBond
virtual bool containsBond(const Bond &bond) const =0
Tells whether the specified bond is part of this molecule.
CDPL::Chem::Molecule::containsAtom
virtual bool containsAtom(const Atom &atom) const =0
Tells whether the specified atom is part of this molecule.
CDPL::Chem::Molecule::copy
virtual void copy(const Molecule &mol)=0
Replaces the current set of atoms, bonds and properties by a copy of the atoms, bonds and properties ...
CDPL::Chem::Molecule::append
virtual void append(const Molecule &mol)=0
Extends the current set of atoms and bonds by a copy of the atoms and bonds in the molecule mol.
CDPL::Chem::Molecule::removeBond
BondIterator removeBond(const BondIterator &it)
Removes the bond specified by the iterator it.
CDPL::Chem::AtomContainer::getAtomsBegin
ConstAtomIterator getAtomsBegin() const
Returns a constant iterator pointing to the beginning of the stored const Chem::Atom objects.
CDPL::Chem::Molecule::ConstAtomIterator
AtomContainer::ConstAtomIterator ConstAtomIterator
A constant random access iterator used to iterate over the atoms of the molecule.
Definition: Molecule.hpp:59
CDPL::Chem::MolecularGraph
MolecularGraph.
Definition: MolecularGraph.hpp:52
CDPL::Chem::Molecule
Molecule.
Definition: Molecule.hpp:48
CDPL::Chem::Molecule::addBond
virtual Bond & addBond(std::size_t atom1_idx, std::size_t atom2_idx)=0
Creates a new or returns an already existing bond between the atoms specified by atom1_idx and atom2_...
CDPL::Chem::Molecule::getNumBonds
virtual std::size_t getNumBonds() const =0
Returns the number of explicit bonds.
CDPL::Chem::Molecule::removeBond
virtual void removeBond(std::size_t idx)=0
Removes the bond at the specified index.
CDPL::Chem::Molecule::getAtomIndex
virtual std::size_t getAtomIndex(const Atom &atom) const =0
Returns the index of the specified atom.
CDPL::Chem::Molecule::addAtom
virtual Atom & addAtom()=0
Creates a new atom and adds it to the molecule.
MolecularGraph.hpp
Definition of the class CDPL::Chem::MolecularGraph.
CDPL::Chem::Molecule::ConstBondIterator
BondContainer::ConstBondIterator ConstBondIterator
A constant random access iterator used to iterate over the bonds of the molecule.
Definition: Molecule.hpp:69
CDPL::Chem::Molecule::AtomIterator
AtomContainer::AtomIterator AtomIterator
A mutable random access iterator used to iterate over the atoms of the molecule.
Definition: Molecule.hpp:64
CDPL::Chem::Molecule::getBond
virtual Bond & getBond(std::size_t idx)=0
Returns a non-const reference to the bond at index idx.
CDPL::Chem::Molecule::append
virtual void append(const MolecularGraph &molgraph)=0
Extends the current set of atoms and bonds by a copy of the atoms and bonds in the molecular graph mo...
CDPL
The namespace of the Chemical Data Processing Library.
CDPL::Chem::Molecule::removeAtom
virtual void removeAtom(std::size_t idx)=0
Removes the atom at the specified index.
CDPL::Chem::Molecule::BondIterator
BondContainer::BondIterator BondIterator
A mutable random access iterator used to iterate over the bonds of the molecule.
Definition: Molecule.hpp:74
CDPL::Chem::Molecule::remove
virtual void remove(const MolecularGraph &molgraph)=0
Removes atoms and bonds referenced by the molecular graph molgraph that are part of this Molecule ins...
CDPL::Chem::Molecule::operator-=
Molecule & operator-=(const MolecularGraph &molgraph)
Removes atoms and bonds referenced by the molecular graph molgraph that are part of this Molecule ins...
CDPL::Chem::Molecule::reserveMemoryForBonds
virtual void reserveMemoryForBonds(std::size_t num_bonds)
Reserves memory for num_bonds bonds.
Definition: Molecule.hpp:286
CDPL::Chem::Molecule::removeAtom
AtomIterator removeAtom(const AtomIterator &it)
Removes the atom specified by the iterator it.
CDPL::Chem::AtomContainer::getAtomsEnd
ConstAtomIterator getAtomsEnd() const
Returns a constant iterator pointing to the end of the stored const Chem::Atom objects.
CDPL::Chem::Molecule::getAtom
virtual const Atom & getAtom(std::size_t idx) const =0
Returns a const reference to the atom at index idx.