The Gnome Chemistry Utils  0.12.13
gcu/residue.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*
4  * Gnome Chemistry Utils
5  * residue.h
6  *
7  * Copyright (C) 2007-2008 Jean Bréfort <jean.brefort@normalesup.org>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 2 of the
12  * License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
22  * USA
23  */
24 
25 #ifndef GCU_RESIDUE_H
26 #define GCU_RESIDUE_H
27 
28 #include "macros.h"
29 #include <libxml/parser.h>
30 #include <map>
31 #include <set>
32 #include <string>
33 
35 namespace gcu {
36 
37 class Residue;
38 class Molecule;
39 class Document;
40 
44 typedef struct {
54  bool ambiguous;
56 
57 typedef std::map<std::string, SymbolResidue>::iterator ResidueIterator;
58 
66 class Residue
67 {
68 public:
72  Residue ();
79  Residue (char const *name, Document *doc = NULL);
83  virtual ~Residue ();
84 
98  std::map<int,int> const &GetRawFormula () const {return m_Raw;}
105  std::map<std::string, bool> const &GetSymbols () const {return m_Symbols;}
110  std::map<std::string, std::string> const &GetNames () const {return m_Names;}
114  void SetName (char const *name);
120  void AddSymbol (char const *symbol);
126  void RemoveSymbol (char const *symbol);
132  virtual void Load (xmlNodePtr node);
140  static Residue const *GetResidue (char const *symbol, bool *ambiguous = NULL);
146  static Residue const *GetResiduebyName (char const *name);
155  static std::string const *GetFirstResidueSymbol (ResidueIterator &i);
165  static std::string const *GetNextResidueSymbol (ResidueIterator &i);
170  virtual bool operator== (G_GNUC_UNUSED Molecule const &mol) const {return false;}
171 
172 public:
177  static unsigned MaxSymbolLength;
178 
179 private:
180  std::map<int,int> m_Raw;
181  std::map<std::string, bool> m_Symbols; // boolean is true if the symbol is ambiguous
182  std::map<std::string, std::string> m_Names;
183 
187 GCU_RO_PROP (char const *, Name)
202 GCU_PROP (bool, Generic)
217 GCU_RO_PROP (Document *, Owner)
218 };
219 
220 } // namespace gcu
221 
222 #endif // GCU_RESIDUE_H