Chemical Data Processing Library C++ API - Version 1.1.1
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
CDPL::ConfGen::FragmentLibrary::containsEntry
bool containsEntry(std::uint64_t hash_code) const
CDPL::ConfGen::FragmentLibrary::get
static const SharedPointer & get()
CDPL::ConfGen::FragmentLibrary::begin
ConstEntryIterator begin() const
CDPL::ConfGen::FragmentLibrary::removeEntry
bool removeEntry(std::uint64_t hash_code)
CDPL::ConfGen::FragmentLibrary::Entry
HashToEntryMap::value_type Entry
Definition: FragmentLibrary.hpp:56
CDPL::ConfGen::FragmentLibrary::getEntry
const FragmentLibraryEntry::SharedPointer & getEntry(std::uint64_t hash_code) const
CDPL::ConfGen::FragmentLibrary::getNumEntries
std::size_t getNumEntries() const
CDPL::ConfGen::FragmentLibrary::clear
void clear()
CDPL::ConfGen::FragmentLibrary::begin
EntryIterator begin()
CDPL::ConfGen::FragmentLibrary::removeEntry
EntryIterator removeEntry(const EntryIterator &it)
CDPL::ConfGen::FragmentLibrary::end
EntryIterator end()
CDPL::ConfGen::FragmentLibrary::loadDefaults
void loadDefaults()
CDPL::ConfGen::FragmentLibrary::addEntries
void addEntries(const FragmentLibrary &lib)
CDPL::ConfGen::FragmentLibrary::SharedPointer
std::shared_ptr< FragmentLibrary > SharedPointer
Definition: FragmentLibrary.hpp:54
CDPL::ConfGen::FragmentLibrary::save
void save(std::ostream &os) const
CDPL::ConfGen::FragmentLibrary::getEntriesEnd
EntryIterator getEntriesEnd()
CDPL::ConfGen::FragmentLibrary::set
static void set(const SharedPointer &lib)
CDPL::ConfGen::FragmentLibrary::ConstEntryIterator
HashToEntryMap::const_iterator ConstEntryIterator
Definition: FragmentLibrary.hpp:57
APIPrefix.hpp
Definition of the preprocessor macro CDPL_CONFGEN_API.
CDPL::ConfGen::FragmentLibrary::EntryIterator
HashToEntryMap::iterator EntryIterator
Definition: FragmentLibrary.hpp:58
CDPL::ConfGen::FragmentLibrary::getEntriesBegin
EntryIterator getEntriesBegin()
CDPL_CONFGEN_API
#define CDPL_CONFGEN_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
CDPL::ConfGen::FragmentLibraryEntry::SharedPointer
std::shared_ptr< FragmentLibraryEntry > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated FragmentLibraryEntry instances.
Definition: FragmentLibraryEntry.hpp:59
CDPL::ConfGen::FragmentLibrary
Definition: FragmentLibrary.hpp:49
CDPL
The namespace of the Chemical Data Processing Library.
CDPL::ConfGen::FragmentLibrary::getEntriesBegin
ConstEntryIterator getEntriesBegin() const
CDPL::ConfGen::FragmentLibrary::addEntry
bool addEntry(const FragmentLibraryEntry::SharedPointer &entry)
CDPL::ConfGen::FragmentLibrary::end
ConstEntryIterator end() const
FragmentLibraryEntry.hpp
Definition of the class CDPL::ConfGen::FragmentLibraryEntry.
CDPL::ConfGen::FragmentLibrary::FragmentLibrary
FragmentLibrary()
CDPL::ConfGen::FragmentLibrary::operator=
FragmentLibrary & operator=(const FragmentLibrary &lib)
CDPL::ConfGen::FragmentLibrary::FragmentLibrary
FragmentLibrary(const FragmentLibrary &lib)
CDPL::ConfGen::FragmentLibrary::getEntriesEnd
ConstEntryIterator getEntriesEnd() const
CDPL::ConfGen::FragmentLibrary::~FragmentLibrary
~FragmentLibrary()
CDPL::ConfGen::FragmentLibrary::load
void load(std::istream &is)
CDPL::ConfGen::FragmentLibrary::getMutex
std::mutex & getMutex()