Chemical Data Processing Library C++ API - Version 1.4.0
HierarchyView.hpp
Go to the documentation of this file.
1 /*
2  * HierarchyView.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_BIOMOL_HIERARCHYVIEW_HPP
30 #define CDPL_BIOMOL_HIERARCHYVIEW_HPP
31 
32 #include <cstddef>
33 #include <vector>
34 #include <unordered_map>
35 #include <mutex>
36 #include <memory>
37 
38 #include <boost/iterator/indirect_iterator.hpp>
39 
43 
44 
45 namespace CDPL
46 {
47 
48  namespace Biomol
49  {
50 
55  {
56 
57  typedef std::shared_ptr<HierarchyViewModel> ModelPtr;
58  typedef std::vector<ModelPtr> ModelList;
59 
60  public:
64  typedef std::shared_ptr<HierarchyView> SharedPointer;
65 
67  typedef boost::indirect_iterator<ModelList::const_iterator, const HierarchyViewModel> ConstModelIterator;
68 
73 
79 
84  const ResidueList& getResidues() const;
85 
90  std::size_t getNumModels() const;
91 
98  const HierarchyViewModel& getModel(std::size_t idx) const;
99 
105  bool hasModelWithNumber(std::size_t num) const;
106 
113  const HierarchyViewModel& getModelByNumber(std::size_t num) const;
114 
120 
126 
132 
138 
143  void build(const Chem::MolecularGraph& molgraph);
144 
145  private:
146  void initModelList() const;
147 
148  typedef std::unordered_map<std::size_t, ModelPtr> IDToModelMap;
149 
150  const Chem::MolecularGraph* molGraph;
151  mutable ResidueList residues;
152  mutable ModelList models;
153  mutable IDToModelMap idToModelMap;
154  mutable bool initResidues;
155  mutable bool initModels;
156  mutable std::mutex initMutex;
157  };
158  } // namespace Biomol
159 } // namespace CDPL
160 
161 #endif // CDPL_BIOMOL_HIERARCHYVIEW_HPP
Definition of the preprocessor macro CDPL_BIOMOL_API.
#define CDPL_BIOMOL_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
Definition of class CDPL::Biomol::HierarchyViewModel.
Definition of class CDPL::Biomol::ResidueList.
Data structure for the representation of individual biological macromolecule models.
Definition: HierarchyViewModel.hpp:57
Data structure providing a hierarchical view on biological macromolecules.
Definition: HierarchyView.hpp:55
const HierarchyViewModel & getModel(std::size_t idx) const
Returns the model at index idx.
ConstModelIterator getModelsBegin() const
Returns a constant iterator pointing to the first model.
const HierarchyViewModel & getModelByNumber(std::size_t num) const
Returns the model identified by model number num.
boost::indirect_iterator< ModelList::const_iterator, const HierarchyViewModel > ConstModelIterator
A constant iterator over the biological macromolecule models.
Definition: HierarchyView.hpp:67
const ResidueList & getResidues() const
Returns the flat list of all residues across all models of the biological macromolecule.
HierarchyView()
Constructs an empty HierarchyView instance.
std::size_t getNumModels() const
Returns the number of stored models.
void build(const Chem::MolecularGraph &molgraph)
Build the hierarchy view for the biological macromolecule represented by molgraph.
ConstModelIterator begin() const
Returns a constant iterator pointing to the first model (range-based for support).
std::shared_ptr< HierarchyView > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated HierarchyView instances.
Definition: HierarchyView.hpp:64
ConstModelIterator getModelsEnd() const
Returns a constant iterator pointing one past the last model.
HierarchyView(const Chem::MolecularGraph &molgraph)
Constructs a HierarchyView instance for the molecular graph molgraph.
bool hasModelWithNumber(std::size_t num) const
Tells whether a model with number num exists.
ConstModelIterator end() const
Returns a constant iterator pointing one past the last model (range-based for support).
Data structure for the storage of residues extracted from biological macromolecules.
Definition: ResidueList.hpp:52
Abstract base class for representations of a chemical structure as a graph of bonded atoms.
Definition: MolecularGraph.hpp:57
The namespace of the Chemical Data Processing Library.