Chemical Data Processing Library C++ API - Version 1.4.0
MMFF94BondChargeIncrementTable.hpp
Go to the documentation of this file.
1 /*
2  * MMFF94BondChargeIncrementTable.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_MMFF94BONDCHARGEINCREMENTTABLE_HPP
30 #define CDPL_FORCEFIELD_MMFF94BONDCHARGEINCREMENTTABLE_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 
57  {
58 
59  public:
60  class Entry;
61 
62  private:
63  typedef std::unordered_map<std::uint32_t, Entry> DataStorage;
64 
65  public:
67  typedef std::shared_ptr<MMFF94BondChargeIncrementTable> SharedPointer;
68 
73  {
74 
75  public:
79  Entry();
80 
88  Entry(unsigned int bond_type_idx, unsigned int atom1_type, unsigned int atom2_type, double bond_chg_inc);
89 
94  unsigned int getBondTypeIndex() const;
95 
100  unsigned int getAtom1Type() const;
101 
106  unsigned int getAtom2Type() const;
107 
112  double getChargeIncrement() const;
113 
118  operator bool() const;
119 
120  private:
121  unsigned int bondTypeIdx;
122  unsigned int atom1Type;
123  unsigned int atom2Type;
124  double chargeIncr;
125  bool initialized;
126  };
127 
129  typedef boost::transform_iterator<std::function<const Entry&(const DataStorage::value_type&)>,
130  DataStorage::const_iterator>
132 
134  typedef boost::transform_iterator<std::function<Entry&(DataStorage::value_type&)>,
135  DataStorage::iterator>
137 
142 
150  void addEntry(unsigned int bond_type_idx, unsigned int atom1_type, unsigned int atom2_type, double bond_chg_inc);
151 
159  const Entry& getEntry(unsigned int bond_type_idx, unsigned int atom1_type, unsigned int atom2_type) const;
160 
165  std::size_t getNumEntries() const;
166 
170  void clear();
171 
179  bool removeEntry(unsigned int bond_type_idx, unsigned int atom1_type, unsigned int atom2_type);
180 
187 
193 
199 
205 
211 
217 
223 
229 
235 
240  void load(std::istream& is);
241 
245  void loadDefaults();
246 
251  static void set(const SharedPointer& table);
252 
257  static const SharedPointer& get();
258 
259  private:
260  static SharedPointer defaultTable;
261  DataStorage entries;
262  };
263  } // namespace ForceField
264 } // namespace CDPL
265 
266 #endif // CDPL_FORCEFIELD_MMFF94BONDCHARGEINCREMENTTABLE_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 bond charge increment table record.
Definition: MMFF94BondChargeIncrementTable.hpp:73
unsigned int getBondTypeIndex() const
Returns the MMFF94 bond type index.
unsigned int getAtom1Type() const
Returns the numeric MMFF94 atom type of the first bonded atom.
unsigned int getAtom2Type() const
Returns the numeric MMFF94 atom type of the second bonded atom.
Entry(unsigned int bond_type_idx, unsigned int atom1_type, unsigned int atom2_type, double bond_chg_inc)
Constructs an Entry for the given (bond type, atom type 1, atom type 2) triple with charge increment ...
Entry()
Constructs an empty (uninitialized) Entry instance.
double getChargeIncrement() const
Returns the bond charge increment.
Lookup table mapping (bond type, atom-type 1, atom-type 2) triples to MMFF94 bond charge increments.
Definition: MMFF94BondChargeIncrementTable.hpp:57
const Entry & getEntry(unsigned int bond_type_idx, unsigned int atom1_type, unsigned int atom2_type) const
Returns the entry for the given (bond type, atom type 1, atom type 2) triple.
ConstEntryIterator getEntriesBegin() const
Returns a constant iterator pointing to the beginning of the entry list.
static const SharedPointer & get()
Returns the process-wide default table (lazily initialized on first call).
EntryIterator removeEntry(const EntryIterator &it)
Removes the entry pointed to by the iterator it.
EntryIterator getEntriesEnd()
Returns a mutable iterator pointing one past the last entry.
EntryIterator getEntriesBegin()
Returns a mutable iterator pointing to the beginning of the entry list.
boost::transform_iterator< std::function< Entry &(DataStorage::value_type &)>, DataStorage::iterator > EntryIterator
A mutable iterator over the entries of the table.
Definition: MMFF94BondChargeIncrementTable.hpp:136
EntryIterator end()
Returns a mutable iterator pointing one past the last entry (alias of getEntriesEnd()).
void load(std::istream &is)
Loads table entries from the input stream is.
EntryIterator begin()
Returns a mutable iterator pointing to the beginning of the entry list (alias of getEntriesBegin()).
void addEntry(unsigned int bond_type_idx, unsigned int atom1_type, unsigned int atom2_type, double bond_chg_inc)
Adds (or overwrites) the entry for the given (bond type, atom type 1, atom type 2) triple.
ConstEntryIterator getEntriesEnd() const
Returns a constant iterator pointing one past the last entry.
void loadDefaults()
Loads the built-in default bond charge increment entries.
void clear()
Removes all entries from the table.
bool removeEntry(unsigned int bond_type_idx, unsigned int atom1_type, unsigned int atom2_type)
Removes the entry for the given (bond type, atom type 1, atom type 2) triple.
std::size_t getNumEntries() const
Returns the number of entries in the table.
ConstEntryIterator end() const
Returns a constant iterator pointing one past the last entry (alias of getEntriesEnd()).
std::shared_ptr< MMFF94BondChargeIncrementTable > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated MMFF94BondChargeIncrementTable in...
Definition: MMFF94BondChargeIncrementTable.hpp:67
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: MMFF94BondChargeIncrementTable.hpp:131
static void set(const SharedPointer &table)
Replaces the process-wide default table by table.
ConstEntryIterator begin() const
Returns a constant iterator pointing to the beginning of the entry list (alias of getEntriesBegin()).
MMFF94BondChargeIncrementTable()
Constructs an empty MMFF94BondChargeIncrementTable instance.
The namespace of the Chemical Data Processing Library.