Chemical Data Processing Library C++ API - Version 1.4.0
BasicBond.hpp
Go to the documentation of this file.
1 /*
2  * BasicBond.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_BASICBOND_HPP
30 #define CDPL_CHEM_BASICBOND_HPP
31 
32 #include "CDPL/Chem/APIPrefix.hpp"
33 #include "CDPL/Chem/Bond.hpp"
34 
35 
36 namespace CDPL
37 {
38 
39  namespace Chem
40  {
41 
42  class BasicMolecule;
43  class BasicAtom;
44 
51  class CDPL_CHEM_API BasicBond : public Bond
52  {
53 
54  friend class BasicMolecule;
55  friend class BasicAtom;
56 
57  public:
62  std::size_t getNumAtoms() const;
63 
68  const Molecule& getMolecule() const;
69 
75 
80  const Atom& getBegin() const;
81 
87 
92  const Atom& getEnd() const;
93 
99 
106  const Atom& getAtom(std::size_t idx) const;
107 
114  Atom& getAtom(std::size_t idx);
115 
121  bool containsAtom(const Atom& atom) const;
122 
129  std::size_t getAtomIndex(const Atom& atom) const;
130 
137  const Atom& getNeighbor(const Atom& atom) const;
138 
145  Atom& getNeighbor(const Atom& atom);
146 
151  std::size_t getIndex() const;
152 
157  void orderAtoms(const AtomCompareFunction& func);
158 
165 
166  using Bond::operator=;
167 
168  private:
169  BasicBond(BasicMolecule* mol);
170 
171  BasicBond(const BasicBond& bond);
172 
173  ~BasicBond();
174 
175  void setIndex(std::size_t idx);
176 
177  void setBegin(BasicAtom& atom);
178  void setEnd(BasicAtom& atom);
179 
180  BasicMolecule* molecule;
181  std::size_t index;
182  BasicAtom* atoms[2];
183  };
184  } // namespace Chem
185 } // namespace CDPL
186 
187 #endif // CDPL_CHEM_BASICBOND_HPP
Definition of class CDPL::Chem::Bond.
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.
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
const Atom & getNeighbor(const Atom &atom) const
Returns the atom on the opposite side of atom.
std::size_t getAtomIndex(const Atom &atom) const
Returns the index of atom within this bond.
Molecule & getMolecule()
Returns the parent molecule.
Atom & getAtom(std::size_t idx)
Returns the bond atom at index idx.
const Atom & getBegin() const
Returns the first atom of the bond.
std::size_t getNumAtoms() const
Returns the number of atoms incident to this bond (always 2).
BasicBond & operator=(const BasicBond &bond)
Assignment operator that replaces the current set of properties with the properties of bond;.
Atom & getEnd()
Returns the second atom of the bond.
bool containsAtom(const Atom &atom) const
Tells whether atom is one of the two bonded atoms.
const Molecule & getMolecule() const
Returns the parent molecule.
std::size_t getIndex() const
Returns the zero-based index of this bond within the parent molecule.
Atom & getNeighbor(const Atom &atom)
Returns the atom on the opposite side of atom.
void orderAtoms(const AtomCompareFunction &func)
Reorders the begin/end atoms of this bond according to the comparison function func.
Atom & getBegin()
Returns the first atom of the bond.
const Atom & getAtom(std::size_t idx) const
Returns the bond atom at index idx.
const Atom & getEnd() const
Returns the second atom of the bond.
Concrete Chem::Molecule implementation that owns Chem::BasicAtom and Chem::BasicBond instances.
Definition: BasicMolecule.hpp:60
Abstract base class representing a chemical bond between two Chem::Atom instances.
Definition: Bond.hpp:54
Abstract base class representing a mutable molecular graph that owns its atoms and bonds.
Definition: Molecule.hpp:53
std::function< bool(const Atom &, const Atom &)> AtomCompareFunction
Generic wrapper class used to store a user-defined atom compare function.
Definition: AtomCompareFunction.hpp:41
The namespace of the Chemical Data Processing Library.