Chemical Data Processing Library C++ API - Version 1.4.0
MMFF94BondStretchingRuleParameterTable.hpp
Go to the documentation of this file.
1 /*
2  * MMFF94BondStretchingRuleParameterTable.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_FORCEFIELD_MMFF94BONDSTRETCHINGRULEPARAMETERTABLE_HPP
30 #define CDPL_FORCEFIELD_MMFF94BONDSTRETCHINGRULEPARAMETERTABLE_HPP
31 
32 #include <cstddef>
33 #include <cstdint>
34 #include <iosfwd>
35 #include <unordered_map>
36 #include <memory>
37 #include <functional>
38 
39 #include <boost/iterator/transform_iterator.hpp>
40 
42 
43 
44 namespace CDPL
45 {
46 
47  namespace ForceField
48  {
49 
55  {
56 
57  public:
58  class Entry;
59 
60  private:
61  typedef std::unordered_map<std::uint32_t, Entry> DataStorage;
62 
63  public:
65  typedef std::shared_ptr<MMFF94BondStretchingRuleParameterTable> SharedPointer;
66 
71  {
72 
73  public:
77  Entry();
78 
86  Entry(unsigned int atomic_no1, unsigned int atomic_no2, double force_const, double ref_length);
87 
92  unsigned int getAtomicNumber1() const;
93 
98  unsigned int getAtomicNumber2() const;
99 
104  double getForceConstant() const;
105 
110  double getReferenceLength() const;
111 
116  operator bool() const;
117 
118  private:
119  unsigned int atomicNo1;
120  unsigned int atomicNo2;
121  double forceConst;
122  double refLength;
123  bool initialized;
124  };
125 
127  typedef boost::transform_iterator<std::function<const Entry&(const DataStorage::value_type&)>,
128  DataStorage::const_iterator>
130 
132  typedef boost::transform_iterator<std::function<Entry&(DataStorage::value_type&)>,
133  DataStorage::iterator>
135 
140 
148  void addEntry(unsigned int atomic_no1, unsigned int atomic_no2, double force_const, double ref_length);
149 
156  const Entry& getEntry(unsigned int atomic_no1, unsigned int atomic_no2) const;
157 
162  std::size_t getNumEntries() const;
163 
167  void clear();
168 
175  bool removeEntry(unsigned int atomic_no1, unsigned int atomic_no2);
176 
183 
189 
195 
201 
207 
213 
219 
225 
231 
236  void load(std::istream& is);
237 
241  void loadDefaults();
242 
247  static void set(const SharedPointer& table);
248 
253  static const SharedPointer& get();
254 
255  private:
256  static SharedPointer defaultTable;
257  DataStorage entries;
258  };
259  } // namespace ForceField
260 } // namespace CDPL
261 
262 #endif // CDPL_FORCEFIELD_MMFF94BONDSTRETCHINGRULEPARAMETERTABLE_HPP
Definition of the preprocessor macro CDPL_FORCEFIELD_API.
#define CDPL_FORCEFIELD_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
A single rule-based bond-stretching parameter record.
Definition: MMFF94BondStretchingRuleParameterTable.hpp:71
double getReferenceLength() const
Returns the reference bond length.
double getForceConstant() const
Returns the bond-stretching force constant.
unsigned int getAtomicNumber2() const
Returns the atomic number of the second bonded atom.
Entry(unsigned int atomic_no1, unsigned int atomic_no2, double force_const, double ref_length)
Constructs an Entry for the given (atomic number 1, atomic number 2) pair.
unsigned int getAtomicNumber1() const
Returns the atomic number of the first bonded atom.
Entry()
Constructs an empty (uninitialized) Entry instance.
Lookup table mapping (atomic-number 1, atomic-number 2) pairs to fallback MMFF94 bond-stretching para...
Definition: MMFF94BondStretchingRuleParameterTable.hpp:55
const Entry & getEntry(unsigned int atomic_no1, unsigned int atomic_no2) const
Returns the entry for the given (atomic number 1, atomic number 2) pair.
static void set(const SharedPointer &table)
Replaces the process-wide default table by table.
void addEntry(unsigned int atomic_no1, unsigned int atomic_no2, double force_const, double ref_length)
Adds (or overwrites) the entry for the given (atomic number 1, atomic number 2) pair.
EntryIterator getEntriesEnd()
Returns a mutable iterator pointing one past the last entry.
ConstEntryIterator end() const
Returns a constant iterator pointing one past the last entry (alias of getEntriesEnd()).
ConstEntryIterator getEntriesEnd() const
Returns a constant iterator pointing one past the last entry.
void load(std::istream &is)
Loads table entries from the input stream is.
void loadDefaults()
Loads the built-in default bond-stretching rule parameter entries.
EntryIterator getEntriesBegin()
Returns a mutable iterator pointing to the beginning of the entry list.
boost::transform_iterator< std::function< const Entry &(const DataStorage::value_type &)>, DataStorage::const_iterator > ConstEntryIterator
A constant iterator over the entries of the table.
Definition: MMFF94BondStretchingRuleParameterTable.hpp:129
std::size_t getNumEntries() const
Returns the number of entries in the table.
MMFF94BondStretchingRuleParameterTable()
Constructs an empty MMFF94BondStretchingRuleParameterTable instance.
static const SharedPointer & get()
Returns the process-wide default table (lazily initialized on first call).
bool removeEntry(unsigned int atomic_no1, unsigned int atomic_no2)
Removes the entry for the given (atomic number 1, atomic number 2) pair.
EntryIterator begin()
Returns a mutable iterator pointing to the beginning of the entry list (alias of getEntriesBegin()).
std::shared_ptr< MMFF94BondStretchingRuleParameterTable > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated MMFF94BondStretchingRuleParameter...
Definition: MMFF94BondStretchingRuleParameterTable.hpp:65
ConstEntryIterator getEntriesBegin() const
Returns a constant iterator pointing to the beginning of the entry list.
ConstEntryIterator begin() const
Returns a constant iterator pointing to the beginning of the entry list (alias of getEntriesBegin()).
boost::transform_iterator< std::function< Entry &(DataStorage::value_type &)>, DataStorage::iterator > EntryIterator
A mutable iterator over the entries of the table.
Definition: MMFF94BondStretchingRuleParameterTable.hpp:134
EntryIterator end()
Returns a mutable iterator pointing one past the last entry (alias of getEntriesEnd()).
EntryIterator removeEntry(const EntryIterator &it)
Removes the entry pointed to by the iterator it.
void clear()
Removes all entries from the table.
The namespace of the Chemical Data Processing Library.