Chemical Data Processing Library C++ API - Version 1.2.1
MMCIFData.hpp
Go to the documentation of this file.
1 /*
2  * MMCIFData.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_MMCIFDATA_HPP
30 #define CDPL_BIOMOL_MMCIFDATA_HPP
31 
32 #include <cstddef>
33 #include <string>
34 #include <memory>
35 #include <iosfwd>
36 
37 #include <boost/ptr_container/ptr_vector.hpp>
38 #include <boost/ptr_container/ptr_deque.hpp>
39 
41 
42 
43 namespace CDPL
44 {
45 
46  namespace Biomol
47  {
48 
54  {
55 
56  public:
57  typedef std::shared_ptr<MMCIFData> SharedPointer;
58 
60  {
61 
62  typedef std::vector<std::string> ValueList;
63 
64  public:
65  typedef ValueList::const_iterator ConstValueIterator;
66  typedef ValueList::iterator ValueIterator;
67 
68  Item(const std::string& name):
69  name(name) {}
70 
71  const std::string& getName() const;
72 
73  std::size_t getNumValues() const;
74 
75  void clear();
76 
77  const std::string& getValue(std::size_t index) const;
78 
79  void setValue(std::size_t index, const std::string& value);
80  void setValue(std::size_t index, std::string&& value);
81 
82  void addValue(const std::string& value);
83  void addValue(std::string&& value);
84 
86 
87  void removeValue(std::size_t index);
88 
89  void swap(Item& item);
90 
92 
94 
96 
98 
100 
102 
104 
106 
107  private:
108  std::string name;
109  ValueList values;
110  };
111 
113  {
114 
115  typedef boost::ptr_vector<Item> ItemList;
116 
117  public:
118  typedef ItemList::const_iterator ConstItemIterator;
119  typedef ItemList::iterator ItemIterator;
120 
121  Category(const std::string& name):
122  name(name) {}
123 
124  const std::string& getName() const;
125 
126  void clear();
127 
128  std::size_t getNumItems() const;
129 
130  Item& getItem(std::size_t index);
131 
132  const Item& getItem(std::size_t index) const;
133 
134  Item& getItem(const std::string& name);
135 
136  const Item& getItem(const std::string& name) const;
137 
138  const Item* findItem(const std::string& name) const;
139 
140  Item* findItem(const std::string& name);
141 
142  Item& addItem(const std::string& name);
143 
145 
146  bool removeItem(const std::string& name);
147 
148  void removeItem(std::size_t index);
149 
150  void swap(Category& cat);
151 
153 
155 
157 
159 
161 
163 
165 
167 
168  std::size_t getNumValueRows() const;
169 
170  private:
171  ItemIterator getItemIter(const std::string& name);
172 
173  ConstItemIterator getItemIter(const std::string& name) const;
174 
175  std::string name;
176  ItemList items;
177  };
178 
179  private:
180  typedef boost::ptr_deque<Category> CategoryList;
181 
182  public:
183  typedef CategoryList::const_iterator ConstCategoryIterator;
184  typedef CategoryList::iterator CategoryIterator;
185 
186  MMCIFData() = default;
187 
188  MMCIFData(const std::string& id);
189 
190  void setID(const std::string& id);
191 
192  const std::string& getID() const;
193 
194  void clear();
195 
196  std::size_t getNumCategories() const;
197 
198  Category& getCategory(std::size_t index);
199 
200  const Category& getCategory(std::size_t index) const;
201 
202  Category& getCategory(const std::string& name);
203 
204  const Category& getCategory(const std::string& name) const;
205 
206  const Category* findCategory(const std::string& name) const;
207 
208  Category* findCategory(const std::string& name);
209 
210  const Category& lastCategory() const;
211 
213 
214  Category& addCategory(const std::string& name, bool front = false);
215 
217 
218  bool removeCategory(const std::string& name);
219 
220  void removeCategory(std::size_t index);
221 
222  void swap(MMCIFData& data);
223 
225 
227 
229 
231 
233 
235 
237 
239 
240  private:
241  CategoryIterator getCategoryIter(const std::string& name);
242 
243  ConstCategoryIterator getCategoryIter(const std::string& name) const;
244 
245  std::string id;
246  CategoryList categories;
247  };
248 
252  CDPL_BIOMOL_API std::ostream& operator<<(std::ostream& os, const MMCIFData& data);
253 
257  CDPL_BIOMOL_API std::ostream& operator<<(std::ostream& os, const MMCIFData::Category& cat);
258 
259  } // namespace Biomol
260 } // namespace CDPL
261 
262 #endif // CDPL_BIOMOL_MMCIFDATA_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: MMCIFData.hpp:113
ConstItemIterator getItemsBegin() const
const Item & getItem(const std::string &name) const
ConstItemIterator end() const
std::size_t getNumItems() const
Item * findItem(const std::string &name)
bool removeItem(const std::string &name)
std::size_t getNumValueRows() const
Item & getItem(std::size_t index)
Item & getItem(const std::string &name)
ItemList::const_iterator ConstItemIterator
Definition: MMCIFData.hpp:118
ConstItemIterator begin() const
ConstItemIterator getItemsEnd() const
ItemIterator removeItem(const ItemIterator &it)
const std::string & getName() const
ItemList::iterator ItemIterator
Definition: MMCIFData.hpp:119
void removeItem(std::size_t index)
Category(const std::string &name)
Definition: MMCIFData.hpp:121
const Item & getItem(std::size_t index) const
const Item * findItem(const std::string &name) const
Item & addItem(const std::string &name)
Definition: MMCIFData.hpp:60
ValueIterator removeValue(const ValueIterator &it)
ConstValueIterator getValuesEnd() const
void addValue(const std::string &value)
ValueList::const_iterator ConstValueIterator
Definition: MMCIFData.hpp:65
Item(const std::string &name)
Definition: MMCIFData.hpp:68
std::size_t getNumValues() const
void setValue(std::size_t index, std::string &&value)
ValueList::iterator ValueIterator
Definition: MMCIFData.hpp:66
ConstValueIterator end() const
void setValue(std::size_t index, const std::string &value)
ConstValueIterator getValuesBegin() const
ValueIterator getValuesBegin()
const std::string & getName() const
ConstValueIterator begin() const
void removeValue(std::size_t index)
const std::string & getValue(std::size_t index) const
void addValue(std::string &&value)
A data structure for the storage of imported MMCIF data (see [MMCIF]).
Definition: MMCIFData.hpp:54
Category & addCategory(const std::string &name, bool front=false)
std::shared_ptr< MMCIFData > SharedPointer
Definition: MMCIFData.hpp:57
const Category & getCategory(std::size_t index) const
const std::string & getID() const
void setID(const std::string &id)
const Category * findCategory(const std::string &name) const
Category & getCategory(const std::string &name)
CategoryIterator end()
CategoryIterator begin()
Category * findCategory(const std::string &name)
std::size_t getNumCategories() const
CategoryIterator removeCategory(const CategoryIterator &it)
const Category & getCategory(const std::string &name) const
CategoryIterator getCategoriesBegin()
bool removeCategory(const std::string &name)
CategoryList::const_iterator ConstCategoryIterator
Definition: MMCIFData.hpp:183
Category & lastCategory()
CategoryList::iterator CategoryIterator
Definition: MMCIFData.hpp:184
ConstCategoryIterator getCategoriesBegin() const
void swap(MMCIFData &data)
CategoryIterator getCategoriesEnd()
Category & getCategory(std::size_t index)
MMCIFData(const std::string &id)
const Category & lastCategory() const
ConstCategoryIterator getCategoriesEnd() const
ConstCategoryIterator end() const
ConstCategoryIterator begin() const
void removeCategory(std::size_t index)
CDPL_BIOMOL_API std::ostream & operator<<(std::ostream &os, const MMCIFData &data)
The namespace of the Chemical Data Processing Library.