Chemical Data Processing Library C++ API - Version 1.4.0
MMFF94PartialBondChargeIncrementTable.hpp
Go to the documentation of this file.
1 /*
2  * MMFF94PartialBondChargeIncrementTable.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_MMFF94PARTIALBONDCHARGEINCREMENTTABLE_HPP
30 #define CDPL_FORCEFIELD_MMFF94PARTIALBONDCHARGEINCREMENTTABLE_HPP
31 
32 #include <iosfwd>
33 #include <cstddef>
34 #include <unordered_map>
35 #include <memory>
36 #include <functional>
37 
38 #include <boost/iterator/transform_iterator.hpp>
39 
41 
42 
43 namespace CDPL
44 {
45 
46  namespace ForceField
47  {
48 
55  {
56 
57  public:
58  class Entry;
59 
60  private:
61  typedef std::unordered_map<unsigned int, Entry> DataStorage;
62 
63  public:
67  typedef std::shared_ptr<MMFF94PartialBondChargeIncrementTable> SharedPointer;
68 
73  {
74 
75  public:
79  Entry();
80 
87  Entry(unsigned int atom_type, double part_bond_chg_inc, double form_chg_adj_factor);
88 
93  unsigned int getAtomType() const;
94 
99  double getPartialChargeIncrement() const;
100 
106 
111  operator bool() const;
112 
113  private:
114  unsigned int atomType;
115  double partChargeIncr;
116  double formChargeAdjFactor;
117  bool initialized;
118  };
119 
123  typedef boost::transform_iterator<std::function<const Entry&(const DataStorage::value_type&)>,
124  DataStorage::const_iterator>
126 
130  typedef boost::transform_iterator<std::function<Entry&(DataStorage::value_type&)>,
131  DataStorage::iterator>
133 
138 
145  void addEntry(unsigned int atom_type, double part_bond_chg_inc, double form_chg_adj_factor);
146 
152  const Entry& getEntry(unsigned int atom_type) const;
153 
158  std::size_t getNumEntries() const;
159 
163  void clear();
164 
170  bool removeEntry(unsigned int atom_type);
171 
178 
184 
190 
196 
202 
208 
214 
220 
226 
231  void load(std::istream& is);
232 
237  void loadDefaults();
238 
243  static void set(const SharedPointer& table);
244 
249  static const SharedPointer& get();
250 
251  private:
252  static SharedPointer defaultTable;
253  DataStorage entries;
254  };
255  } // namespace ForceField
256 } // namespace CDPL
257 
258 #endif // CDPL_FORCEFIELD_MMFF94PARTIALBONDCHARGEINCREMENTTABLE_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: MMFF94PartialBondChargeIncrementTable.hpp:73
double getPartialChargeIncrement() const
Returns the partial bond charge increment.
double getFormalChargeAdjustmentFactor() const
Returns the formal charge adjustment factor.
Entry(unsigned int atom_type, double part_bond_chg_inc, double form_chg_adj_factor)
Constructs an Entry instance storing the given values.
unsigned int getAtomType() const
Returns the numeric MMFF94 atom type of the entry.
Entry()
Constructs an empty (uninitialized) Entry instance.
Data structure for the storage and lookup of MMFF94 per-atom partial bond charge increment and formal...
Definition: MMFF94PartialBondChargeIncrementTable.hpp:55
ConstEntryIterator getEntriesBegin() const
Returns a constant iterator pointing to the beginning of the entry list.
void loadDefaults()
Loads the built-in default MMFF94 partial bond charge increment and formal charge adjustment factors.
void clear()
Removes all entries from the table.
EntryIterator getEntriesEnd()
Returns a mutable iterator pointing one past the last entry.
static void set(const SharedPointer &table)
Replaces the process-wide default table by table.
static const SharedPointer & get()
Returns the process-wide default table (lazily initialized on first call).
void addEntry(unsigned int atom_type, double part_bond_chg_inc, double form_chg_adj_factor)
Adds a new (or overwrites an existing) entry for the numeric MMFF94 atom type atom_type that stores t...
ConstEntryIterator getEntriesEnd() const
Returns a constant iterator pointing one past the last entry.
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: MMFF94PartialBondChargeIncrementTable.hpp:125
const Entry & getEntry(unsigned int atom_type) const
Returns the entry for the numeric MMFF94 atom type atom_type.
bool removeEntry(unsigned int atom_type)
Removes the entry for the numeric MMFF94 atom type atom_type.
std::shared_ptr< MMFF94PartialBondChargeIncrementTable > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated MMFF94PartialBondChargeIncrementT...
Definition: MMFF94PartialBondChargeIncrementTable.hpp:67
EntryIterator end()
Returns a mutable iterator pointing one past the last entry (alias of getEntriesEnd()).
EntryIterator getEntriesBegin()
Returns a mutable iterator pointing to the beginning of the entry list.
std::size_t getNumEntries() const
Returns the number of entries in the table.
MMFF94PartialBondChargeIncrementTable()
Constructs an empty MMFF94PartialBondChargeIncrementTable instance.
EntryIterator begin()
Returns a mutable iterator pointing to the beginning of the entry list (alias of getEntriesBegin()).
EntryIterator removeEntry(const EntryIterator &it)
Removes the entry pointed to by the iterator it.
void load(std::istream &is)
Loads table entries from the input stream is.
ConstEntryIterator begin() const
Returns a constant iterator pointing to the beginning of the entry list (alias of getEntriesBegin()).
ConstEntryIterator end() const
Returns a constant iterator pointing one past the last entry (alias of getEntriesEnd()).
boost::transform_iterator< std::function< Entry &(DataStorage::value_type &)>, DataStorage::iterator > EntryIterator
A mutable iterator over the entries of the table.
Definition: MMFF94PartialBondChargeIncrementTable.hpp:132
The namespace of the Chemical Data Processing Library.