Chemical Data Processing Library C++ API - Version 1.4.0
MMFF94BondStretchingParameterTable.hpp
Go to the documentation of this file.
1 /*
2  * MMFF94BondStretchingParameterTable.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_MMFF94BONDSTRETCHINGPARAMETERTABLE_HPP
30 #define CDPL_FORCEFIELD_MMFF94BONDSTRETCHINGPARAMETERTABLE_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 
54  {
55 
56  public:
57  class Entry;
58 
59  private:
60  typedef std::unordered_map<std::uint32_t, Entry> DataStorage;
61 
62  public:
64  typedef std::shared_ptr<MMFF94BondStretchingParameterTable> SharedPointer;
65 
70  {
71 
72  public:
76  Entry();
77 
86  Entry(unsigned int bond_type_idx, unsigned int atom1_type, unsigned int atom2_type,
87  double force_const, double ref_length);
88 
93  unsigned int getBondTypeIndex() const;
94 
99  unsigned int getAtom1Type() const;
100 
105  unsigned int getAtom2Type() const;
106 
111  double getForceConstant() const;
112 
117  double getReferenceLength() const;
118 
123  operator bool() const;
124 
125  private:
126  unsigned int bondTypeIdx;
127  unsigned int atom1Type;
128  unsigned int atom2Type;
129  double forceConst;
130  double refLength;
131  bool initialized;
132  };
133 
135  typedef boost::transform_iterator<std::function<const Entry&(const DataStorage::value_type&)>,
136  DataStorage::const_iterator>
138 
140  typedef boost::transform_iterator<std::function<Entry&(DataStorage::value_type&)>,
141  DataStorage::iterator>
143 
148 
157  void addEntry(unsigned int bond_type_idx, unsigned int atom1_type, unsigned int atom2_type,
158  double force_const, double ref_length);
159 
167  const Entry& getEntry(unsigned int bond_type_idx, unsigned int atom1_type, unsigned int atom2_type) const;
168 
173  std::size_t getNumEntries() const;
174 
178  void clear();
179 
187  bool removeEntry(unsigned int bond_type_idx, unsigned int atom1_type, unsigned int atom2_type);
188 
195 
201 
207 
213 
219 
225 
231 
237 
243 
248  void load(std::istream& is);
249 
253  void loadDefaults();
254 
259  static void set(const SharedPointer& table);
260 
265  static const SharedPointer& get();
266 
267  private:
268  static SharedPointer defaultTable;
269  DataStorage entries;
270  };
271  } // namespace ForceField
272 } // namespace CDPL
273 
274 #endif // CDPL_FORCEFIELD_MMFF94BONDSTRETCHINGPARAMETERTABLE_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.
Data structure for the storage of values associated with a single parameter table entry.
Definition: MMFF94BondStretchingParameterTable.hpp:70
Entry()
Constructs an empty (uninitialized) parameter entry.
unsigned int getBondTypeIndex() const
Returns the MMFF94 bond type index.
double getReferenceLength() const
Returns the reference bond length.
double getForceConstant() const
Returns the bond-stretching force constant.
unsigned int getAtom2Type() const
Returns the numeric MMFF94 atom type of the second bonded atom.
unsigned int getAtom1Type() const
Returns the numeric MMFF94 atom type of the first bonded atom.
Entry(unsigned int bond_type_idx, unsigned int atom1_type, unsigned int atom2_type, double force_const, double ref_length)
Constructs an entry for the given query and parameter values.
Data structure for the storage and lookup of MMFF94 bond-stretching interaction parameters.
Definition: MMFF94BondStretchingParameterTable.hpp:54
ConstEntryIterator getEntriesEnd() const
Returns a constant iterator pointing one past the last entry.
static const SharedPointer & get()
Returns the process-wide default table (lazily initialized on first call).
MMFF94BondStretchingParameterTable()
Constructs an empty MMFF94BondStretchingParameterTable instance.
boost::transform_iterator< std::function< Entry &(DataStorage::value_type &)>, DataStorage::iterator > EntryIterator
A mutable iterator over the entries of the table.
Definition: MMFF94BondStretchingParameterTable.hpp:142
EntryIterator begin()
Returns a mutable iterator pointing to the beginning of the entry list (alias of getEntriesBegin()).
bool removeEntry(unsigned int bond_type_idx, unsigned int atom1_type, unsigned int atom2_type)
Removes the entry matching the specified query values.
void load(std::istream &is)
Loads table entries from the input stream is.
ConstEntryIterator getEntriesBegin() const
Returns a constant iterator pointing to the beginning of the entry list.
void loadDefaults()
Loads the built-in default bond-stretching parameter entries.
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()).
EntryIterator getEntriesBegin()
Returns a mutable iterator pointing to the beginning of the entry list.
static void set(const SharedPointer &table)
Replaces the process-wide default table by table.
void clear()
Removes all entries from the table.
std::size_t getNumEntries() const
Returns the number of entries in the table.
EntryIterator end()
Returns a mutable iterator pointing one past the last entry (alias of getEntriesEnd()).
ConstEntryIterator begin() const
Returns a constant iterator pointing to the beginning of the entry list (alias of getEntriesBegin()).
const Entry & getEntry(unsigned int bond_type_idx, unsigned int atom1_type, unsigned int atom2_type) const
Returns a reference to the entry matching the specified query values.
void addEntry(unsigned int bond_type_idx, unsigned int atom1_type, unsigned int atom2_type, double force_const, double ref_length)
Adds a new (or overwrites an existing) entry for the given query and parameter values.
std::shared_ptr< MMFF94BondStretchingParameterTable > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated MMFF94BondStretchingParameterTabl...
Definition: MMFF94BondStretchingParameterTable.hpp:64
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: MMFF94BondStretchingParameterTable.hpp:137
EntryIterator removeEntry(const EntryIterator &it)
Removes the entry pointed to by the iterator it.
The namespace of the Chemical Data Processing Library.