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 
61  {
62 
63  public:
64  class Entry;
65 
66  private:
67  typedef std::unordered_map<std::string, Entry> DataStorage;
68 
69  public:
73  typedef std::shared_ptr<MMFF94FormalAtomChargeDefinitionTable> SharedPointer;
74 
79  {
80 
81  public:
85  Entry();
86 
94  Entry(const std::string& atom_type, std::size_t ass_mode, double charge, const std::string& type_list);
95 
100  const std::string& getAtomType() const;
101 
106  std::size_t getAssignmentMode() const;
107 
112  double getFormalCharge() const;
113 
118  const std::string& getAtomTypeList() const;
119 
124  operator bool() const;
125 
126  private:
127  std::string atomType;
128  std::size_t assMode;
129  double charge;
130  std::string typeList;
131  bool initialized;
132  };
133 
137  typedef boost::transform_iterator<std::function<const Entry&(const DataStorage::value_type&)>,
138  DataStorage::const_iterator>
140 
144  typedef boost::transform_iterator<std::function<Entry&(DataStorage::value_type&)>,
145  DataStorage::iterator>
147 
152 
160  void addEntry(const std::string& atom_type, std::size_t ass_mode, double charge, const std::string& nbr_types);
161 
167  const Entry& getEntry(const std::string& atom_type) const;
168 
173  std::size_t getNumEntries() const;
174 
178  void clear();
179 
185  bool removeEntry(const std::string& atom_type);
186 
193 
199 
205 
211 
217 
223 
229 
235 
241 
246  void load(std::istream& is);
247 
251  void loadDefaults();
252 
257  static void set(const SharedPointer& table);
258 
263  static const SharedPointer& get();
264 
265  private:
266  static SharedPointer defaultTable;
267  DataStorage entries;
268  };
269  } // namespace ForceField
270 } // namespace CDPL
271 
272 #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.
Data structure for the storage of values associated with a single table entry.
Definition: MMFF94FormalAtomChargeDefinitionTable.hpp:79
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 instance storing the given values.
Data structure for the storage and lookup of formal charge definitions used by the MMFF94 charge mode...
Definition: MMFF94FormalAtomChargeDefinitionTable.hpp:61
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 MMFF94 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:146
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 MMFF94 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 a new (or overwrites an existing) entry for the symbolic MMFF94 atom type atom_type that stores ...
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:139
std::shared_ptr< MMFF94FormalAtomChargeDefinitionTable > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated MMFF94FormalAtomChargeDefinitionT...
Definition: MMFF94FormalAtomChargeDefinitionTable.hpp:73
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.