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:
58  std::size_t getNumAtoms() const;
59 
60  const Molecule& getMolecule() const;
61 
63 
64  const Atom& getBegin() const;
65 
67 
68  const Atom& getEnd() const;
69 
71 
72  const Atom& getAtom(std::size_t idx) const;
73 
74  Atom& getAtom(std::size_t idx);
75 
76  bool containsAtom(const Atom& atom) const;
77 
78  std::size_t getAtomIndex(const Atom& atom) const;
79 
80  const Atom& getNeighbor(const Atom& atom) const;
81 
82  Atom& getNeighbor(const Atom& atom);
83 
84  std::size_t getIndex() const;
85 
86  void orderAtoms(const AtomCompareFunction& func);
87 
93  BasicBond& operator=(const BasicBond& bond);
94 
95  using Bond::operator=;
96 
97  private:
99 
100  BasicBond(const BasicBond& bond);
101 
102  ~BasicBond();
103 
104  void setIndex(std::size_t idx);
105 
106  void setBegin(BasicAtom& atom);
107  void setEnd(BasicAtom& atom);
108 
109  BasicMolecule* molecule;
110  std::size_t index;
111  BasicAtom* atoms[2];
112  };
113  } // namespace Chem
114 } // namespace CDPL
115 
116 #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:58
Default implementation of the Chem::Atom interface.
Definition: BasicAtom.hpp:57
Default implementation of the Chem::Bond interface.
Definition: BasicBond.hpp:52
const Atom & getNeighbor(const Atom &atom) const
Returns a const reference to the connected neighbor of the argument atom.
std::size_t getAtomIndex(const Atom &atom) const
Returns the index of the specified atom.
Molecule & getMolecule()
Returns a non-const reference to the parent molecule.
Atom & getAtom(std::size_t idx)
Returns a non-const reference to the atom at index idx.
const Atom & getBegin() const
Returns a const reference to the start atom of the bond.
std::size_t getNumAtoms() const
Returns the number of atoms connected by the bond.
BasicBond & operator=(const BasicBond &bond)
Assignment operator that replaces the current set of properties with the properties of bond.
Atom & getEnd()
Returns a non-const reference to the end atom of the bond.
bool containsAtom(const Atom &atom) const
Tells whether the bond is incident to the specified atom.
const Molecule & getMolecule() const
Returns a const reference to the parent molecule.
std::size_t getIndex() const
Returns the index of the bond in its parent molecule.
Atom & getNeighbor(const Atom &atom)
Returns a non-const reference to the connected neighbor of the argument atom.
void orderAtoms(const AtomCompareFunction &func)
Orders the atoms according to criteria implemented by the provided atom comparison function.
Atom & getBegin()
Returns a non-const reference to the start atom of the bond.
const Atom & getAtom(std::size_t idx) const
Returns a const reference to the atom at index idx.
const Atom & getEnd() const
Returns a const reference to the end atom of the bond.
Default implementation of the Chem::Molecule interface.
Definition: BasicMolecule.hpp:58
Abstract base class representing a chemical bond between two atoms (represented by Chem::Atom instanc...
Definition: Bond.hpp:54
Abstract base class representing a mutable molecular graph that owns and manages 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.