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:
67  typedef std::shared_ptr<MMFF94BondStretchingRuleParameterTable> SharedPointer;
68 
73  {
74 
75  public:
79  Entry();
80 
88  Entry(unsigned int atomic_no1, unsigned int atomic_no2, double force_const, double ref_length);
89 
94  unsigned int getAtomicNumber1() const;
95 
100  unsigned int getAtomicNumber2() const;
101 
106  double getForceConstant() const;
107 
112  double getReferenceLength() const;
113 
118  operator bool() const;
119 
120  private:
121  unsigned int atomicNo1;
122  unsigned int atomicNo2;
123  double forceConst;
124  double refLength;
125  bool initialized;
126  };
127 
131  typedef boost::transform_iterator<std::function<const Entry&(const DataStorage::value_type&)>,
132  DataStorage::const_iterator>
134 
138  typedef boost::transform_iterator<std::function<Entry&(DataStorage::value_type&)>,
139  DataStorage::iterator>
141 
146 
154  void addEntry(unsigned int atomic_no1, unsigned int atomic_no2, double force_const, double ref_length);
155 
162  const Entry& getEntry(unsigned int atomic_no1, unsigned int atomic_no2) const;
163 
168  std::size_t getNumEntries() const;
169 
173  void clear();
174 
181  bool removeEntry(unsigned int atomic_no1, unsigned int atomic_no2);
182 
189 
195 
201 
207 
213 
219 
225 
231 
237 
242  void load(std::istream& is);
243 
247  void loadDefaults();
248 
253  static void set(const SharedPointer& table);
254 
259  static const SharedPointer& get();
260 
261  private:
262  static SharedPointer defaultTable;
263  DataStorage entries;
264  };
265  } // namespace ForceField
266 } // namespace CDPL
267 
268 #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.
Data structure for the storage of values associated with a single table entry.
Definition: MMFF94BondStretchingRuleParameterTable.hpp:73
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 instance storing the given query and parameter values.
unsigned int getAtomicNumber1() const
Returns the atomic number of the first bonded atom.
Entry()
Constructs an empty (uninitialized) Entry instance.
Data structure for the storage and lookup of MMFF94 bond-stretching interaction fallback parameters.
Definition: MMFF94BondStretchingRuleParameterTable.hpp:55
const Entry & getEntry(unsigned int atomic_no1, unsigned int atomic_no2) const
Returns a reference to the entry matching the specified query values.
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 a new (or overwrites an existing) entry for the given query and parameter values.
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 MMFF94 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:133
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 matching the specified query values.
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:67
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:140
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.