Chemical Data Processing Library C++ API - Version 1.4.0
MMFF94FormalAtomChargeDefinitionTable.hpp
Go to the documentation of this file.
1 /*
2  * MMFF94FormalAtomChargeDefinitionTable.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_MMFF94FORMALATOMCHARGEDEFINITIONTABLE_HPP
30 #define CDPL_FORCEFIELD_MMFF94FORMALATOMCHARGEDEFINITIONTABLE_HPP
31 
32 #include <cstddef>
33 #include <iosfwd>
34 #include <string>
35 #include <vector>
36 #include <unordered_map>
37 #include <memory>
38 #include <functional>
39 
40 #include <boost/iterator/transform_iterator.hpp>
41 
43 
44 
45 namespace CDPL
46 {
47 
48  namespace ForceField
49  {
50 
59  {
60 
61  public:
62  class Entry;
63 
64  private:
65  typedef std::unordered_map<std::string, Entry> DataStorage;
66 
67  public:
69  typedef std::shared_ptr<MMFF94FormalAtomChargeDefinitionTable> SharedPointer;
70 
75  {
76 
77  public:
81  Entry();
82 
90  Entry(const std::string& atom_type, std::size_t ass_mode, double charge, const std::string& type_list);
91 
96  const std::string& getAtomType() const;
97 
102  std::size_t getAssignmentMode() const;
103 
108  double getFormalCharge() const;
109 
114  const std::string& getAtomTypeList() const;
115 
120  operator bool() const;
121 
122  private:
123  std::string atomType;
124  std::size_t assMode;
125  double charge;
126  std::string typeList;
127  bool initialized;
128  };
129 
131  typedef boost::transform_iterator<std::function<const Entry&(const DataStorage::value_type&)>,
132  DataStorage::const_iterator>
134 
136  typedef boost::transform_iterator<std::function<Entry&(DataStorage::value_type&)>,
137  DataStorage::iterator>
139 
144 
152  void addEntry(const std::string& atom_type, std::size_t ass_mode, double charge, const std::string& nbr_types);
153 
159  const Entry& getEntry(const std::string& atom_type) const;
160 
165  std::size_t getNumEntries() const;
166 
170  void clear();
171 
177  bool removeEntry(const std::string& atom_type);
178 
185 
191 
197 
203 
209 
215 
221 
227 
233 
238  void load(std::istream& is);
239 
243  void loadDefaults();
244 
249  static void set(const SharedPointer& table);
250 
255  static const SharedPointer& get();
256 
257  private:
258  static SharedPointer defaultTable;
259  DataStorage entries;
260  };
261  } // namespace ForceField
262 } // namespace CDPL
263 
264 #endif // CDPL_FORCEFIELD_MMFF94FORMALATOMCHARGEDEFINITIONTABLE_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 formal-charge definition.
Definition: MMFF94FormalAtomChargeDefinitionTable.hpp:75
std::size_t getAssignmentMode() const
Returns the charge-assignment mode flag.
double getFormalCharge() const
Returns the formal charge of the entry.
const std::string & getAtomTypeList() const
Returns the whitespace-separated list of neighbour atom types used by the assignment.
const std::string & getAtomType() const
Returns the symbolic MMFF94 atom type of the entry.
Entry()
Constructs an empty (uninitialized) Entry instance.
Entry(const std::string &atom_type, std::size_t ass_mode, double charge, const std::string &type_list)
Constructs an Entry for the symbolic MMFF94 atom type atom_type.
Lookup table mapping symbolic MMFF94 atom types to their formal-charge definitions used by the MMFF94...
Definition: MMFF94FormalAtomChargeDefinitionTable.hpp:59
const Entry & getEntry(const std::string &atom_type) const
Returns the entry for the symbolic MMFF94 atom type atom_type.
EntryIterator begin()
Returns a mutable iterator pointing to the beginning of the entry list (alias of getEntriesBegin()).
std::size_t getNumEntries() const
Returns the number of entries in the table.
EntryIterator removeEntry(const EntryIterator &it)
Removes the entry pointed to by the iterator it.
ConstEntryIterator begin() const
Returns a constant iterator pointing to the beginning of the entry list (alias of getEntriesBegin()).
void loadDefaults()
Loads the built-in default formal-charge definitions.
static const SharedPointer & get()
Returns the process-wide default table (lazily initialized on first call).
ConstEntryIterator getEntriesBegin() const
Returns a constant iterator pointing to the beginning of the entry list.
ConstEntryIterator getEntriesEnd() const
Returns a constant iterator pointing one past the last entry.
boost::transform_iterator< std::function< Entry &(DataStorage::value_type &)>, DataStorage::iterator > EntryIterator
A mutable iterator over the entries of the table.
Definition: MMFF94FormalAtomChargeDefinitionTable.hpp:138
ConstEntryIterator end() const
Returns a constant iterator pointing one past the last entry (alias of getEntriesEnd()).
bool removeEntry(const std::string &atom_type)
Removes the entry for the symbolic atom type atom_type.
MMFF94FormalAtomChargeDefinitionTable()
Constructs an empty MMFF94FormalAtomChargeDefinitionTable instance.
void addEntry(const std::string &atom_type, std::size_t ass_mode, double charge, const std::string &nbr_types)
Adds (or overwrites) the formal-charge definition for the symbolic atom type atom_type.
void clear()
Removes all entries from the table.
void load(std::istream &is)
Loads table entries from the input stream is.
static void set(const SharedPointer &table)
Replaces the process-wide default table by table.
EntryIterator end()
Returns a mutable iterator pointing one past the last entry (alias of getEntriesEnd()).
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: MMFF94FormalAtomChargeDefinitionTable.hpp:133
std::shared_ptr< MMFF94FormalAtomChargeDefinitionTable > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated MMFF94FormalAtomChargeDefinitionT...
Definition: MMFF94FormalAtomChargeDefinitionTable.hpp:69
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.
The namespace of the Chemical Data Processing Library.