Chemical Data Processing Library C++ API - Version 1.2.0
CIPPriorityCalculator.hpp
Go to the documentation of this file.
1 /*
2  * CIPPriorityCalculator.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_CIPPRIORITYCALCULATOR_HPP
30 #define CDPL_CHEM_CIPPRIORITYCALCULATOR_HPP
31 
32 #include <cstddef>
33 #include <vector>
34 
35 #include "CDPL/Chem/APIPrefix.hpp"
36 #include "CDPL/Util/Array.hpp"
38 
39 
40 namespace CDPL
41 {
42 
43  namespace Chem
44  {
45 
46  class MolecularGraph;
47  class Atom;
48 
54  {
55 
56  public:
61 
70  CIPPriorityCalculator(const MolecularGraph& molgraph, Util::STArray& priorities);
71 
73 
75 
83  void calculate(const MolecularGraph& molgraph, Util::STArray& priorities);
84 
85  private:
86  class AtomNode;
87 
88  void init(const MolecularGraph&, Util::STArray&);
89  void determinePriorities(Util::STArray&);
90 
91  AtomNode* allocNode(std::size_t p);
92 
93  typedef std::vector<AtomNode*> NodeList;
94 
95  class AtomNode
96  {
97 
98  public:
99  void clear();
100 
101  void addNbrNode(AtomNode*);
102 
103  void setNewPriority(std::size_t);
104 
105  void updateNbrList();
106  void updatePriority();
107 
108  void setPriority(std::size_t p);
109 
110  std::size_t getPriority() const;
111 
112  struct LessCmpFunc
113  {
114 
115  bool operator()(const AtomNode*, const AtomNode*) const;
116  };
117 
119  {
120 
121  bool operator()(const AtomNode*, const AtomNode*) const;
122  };
123 
125  {
126 
127  bool operator()(const AtomNode*, const AtomNode*) const;
128  };
129 
130  private:
131  std::size_t priority;
132  std::size_t newPriority;
133  NodeList nbrNodes;
134  };
135 
137 
138  NodeCache nodeCache;
139  NodeList expAtomNodes;
140  NodeList atomNodes;
141  };
142  } // namespace Chem
143 } // namespace CDPL
144 
145 #endif // CDPL_CHEM_CIPPRIORITYCALCULATOR_HPP
Definition of the class CDPL::Util::Array.
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 the class CDPL::Util::ObjectStack.
CIPPriorityCalculator.
Definition: CIPPriorityCalculator.hpp:54
CIPPriorityCalculator & operator=(const CIPPriorityCalculator &)=delete
CIPPriorityCalculator(const CIPPriorityCalculator &)=delete
CIPPriorityCalculator()
Constructs the CIPPriorityCalculator instance.
CIPPriorityCalculator(const MolecularGraph &molgraph, Util::STArray &priorities)
Constructs the CIPPriorityCalculator instance and calculates the topological CIP priorities of the at...
void calculate(const MolecularGraph &molgraph, Util::STArray &priorities)
Calculates the topological CIP priorities of the atoms in the molecular graph molgraph.
MolecularGraph.
Definition: MolecularGraph.hpp:52
constexpr unsigned int p
Specifies that the stereocenter has p configuration.
Definition: CIPDescriptor.hpp:121
Array< std::size_t > STArray
An array of unsigned integers of type std::size_t.
Definition: Array.hpp:567
The namespace of the Chemical Data Processing Library.
Definition: CIPPriorityCalculator.hpp:113
bool operator()(const AtomNode *, const AtomNode *) const
bool operator()(const AtomNode *, const AtomNode *) const
bool operator()(const AtomNode *, const AtomNode *) const