Chemical Data Processing Library C++ API - Version 1.2.0
FragmentLibrary.hpp
Go to the documentation of this file.
1 /*
2  * FragmentLibrary.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_CONFGEN_FRAGMENTLIBRARY_HPP
30 #define CDPL_CONFGEN_FRAGMENTLIBRARY_HPP
31 
32 #include <iosfwd>
33 #include <cstddef>
34 #include <unordered_map>
35 #include <mutex>
36 #include <memory>
37 
40 
41 
42 namespace CDPL
43 {
44 
45  namespace ConfGen
46  {
47 
49  {
50 
51  typedef std::unordered_map<std::uint64_t, FragmentLibraryEntry::SharedPointer> HashToEntryMap;
52 
53  public:
54  typedef std::shared_ptr<FragmentLibrary> SharedPointer;
55 
56  typedef HashToEntryMap::value_type Entry;
57  typedef HashToEntryMap::const_iterator ConstEntryIterator;
58  typedef HashToEntryMap::iterator EntryIterator;
59 
61 
63 
65 
67 
68  void addEntries(const FragmentLibrary& lib);
69 
71 
72  const FragmentLibraryEntry::SharedPointer& getEntry(std::uint64_t hash_code) const;
73 
74  bool containsEntry(std::uint64_t hash_code) const;
75 
76  std::size_t getNumEntries() const;
77 
78  void clear();
79 
80  bool removeEntry(std::uint64_t hash_code);
81 
83 
85 
87 
89 
91 
93 
95 
97 
99 
100  void load(std::istream& is);
101 
102  void save(std::ostream& os) const;
103 
104  void loadDefaults();
105 
106  std::mutex& getMutex();
107 
108  static void set(const SharedPointer& lib);
109 
110  static const SharedPointer& get();
111 
112  private:
113  static SharedPointer defaultLib;
114  mutable HashToEntryMap hashToEntryMap;
115  mutable std::mutex mutex;
116  };
117  } // namespace ConfGen
118 } // namespace CDPL
119 
120 #endif // CDPL_CONFGEN_FRAGMENTLIBRARY_HPP
Definition of the preprocessor macro CDPL_CONFGEN_API.
#define CDPL_CONFGEN_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
Definition of the class CDPL::ConfGen::FragmentLibraryEntry.
std::shared_ptr< FragmentLibraryEntry > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated FragmentLibraryEntry instances.
Definition: FragmentLibraryEntry.hpp:59
Definition: FragmentLibrary.hpp:49
std::shared_ptr< FragmentLibrary > SharedPointer
Definition: FragmentLibrary.hpp:54
ConstEntryIterator end() const
std::size_t getNumEntries() const
HashToEntryMap::value_type Entry
Definition: FragmentLibrary.hpp:56
HashToEntryMap::iterator EntryIterator
Definition: FragmentLibrary.hpp:58
bool containsEntry(std::uint64_t hash_code) const
bool removeEntry(std::uint64_t hash_code)
static void set(const SharedPointer &lib)
const FragmentLibraryEntry::SharedPointer & getEntry(std::uint64_t hash_code) const
EntryIterator removeEntry(const EntryIterator &it)
static const SharedPointer & get()
void save(std::ostream &os) const
FragmentLibrary & operator=(const FragmentLibrary &lib)
FragmentLibrary(const FragmentLibrary &lib)
void addEntries(const FragmentLibrary &lib)
bool addEntry(const FragmentLibraryEntry::SharedPointer &entry)
ConstEntryIterator getEntriesBegin() const
ConstEntryIterator getEntriesEnd() const
void load(std::istream &is)
HashToEntryMap::const_iterator ConstEntryIterator
Definition: FragmentLibrary.hpp:57
ConstEntryIterator begin() const
The namespace of the Chemical Data Processing Library.