Chemical Data Processing Library C++ API - Version 1.1.1
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 
79  void calculate(const MolecularGraph& molgraph, Util::STArray& priorities);
80 
81  private:
82  class AtomNode;
83 
85 
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
CDPL::Chem::CIPDescriptor::p
const unsigned int p
Specifies that the stereocenter has p configuration.
Definition: CIPDescriptor.hpp:121
ObjectStack.hpp
Definition of the class CDPL::Util::ObjectStack.
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::CIPPriorityCalculator::AtomNode::PriorityLessCmpFunc::operator()
bool operator()(const AtomNode *, const AtomNode *) const
CDPL::Chem::MolecularGraph
MolecularGraph.
Definition: MolecularGraph.hpp:52
Array.hpp
Definition of the class CDPL::Util::Array.
CDPL::Chem::CIPPriorityCalculator
CIPPriorityCalculator.
Definition: CIPPriorityCalculator.hpp:54
CDPL::Chem::CIPPriorityCalculator::AtomNode::LessCmpFunc::operator()
bool operator()(const AtomNode *, const AtomNode *) const
CDPL::Chem::CIPPriorityCalculator::AtomNode::PriorityGreaterCmpFunc
Definition: CIPPriorityCalculator.hpp:125
CDPL::Chem::CIPPriorityCalculator::AtomNode::PriorityLessCmpFunc
Definition: CIPPriorityCalculator.hpp:119
CDPL
The namespace of the Chemical Data Processing Library.
CDPL::Util::STArray
Array< std::size_t > STArray
An array of unsigned integers of type std::size_t.
Definition: Array.hpp:567
CDPL::Chem::CIPPriorityCalculator::AtomNode::LessCmpFunc
Definition: CIPPriorityCalculator.hpp:113
CDPL::Chem::CIPPriorityCalculator::calculate
void calculate(const MolecularGraph &molgraph, Util::STArray &priorities)
Calculates the topological CIP priorities of the atoms in the molecular graph molgraph.
CDPL::Util::ObjectStack< AtomNode >
CDPL::Chem::CIPPriorityCalculator::AtomNode::PriorityGreaterCmpFunc::operator()
bool operator()(const AtomNode *, const AtomNode *) const
CDPL::Chem::CIPPriorityCalculator::CIPPriorityCalculator
CIPPriorityCalculator()
Constructs the CIPPriorityCalculator instance.
CDPL::Chem::CIPPriorityCalculator::CIPPriorityCalculator
CIPPriorityCalculator(const MolecularGraph &molgraph, Util::STArray &priorities)
Constructs the CIPPriorityCalculator instance and calculates the topological CIP priorities of the at...