The Gnome Chemistry Utils  0.14.0
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 3 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 Application;
38 class Residue;
39 class Molecule;
40 class Document;
41 
45 typedef struct {
55  bool ambiguous;
57 
58 typedef std::map<std::string, SymbolResidue>::iterator ResidueIterator;
59 
67 class Residue
68 {
69 public:
73  Residue ();
80  Residue (char const *name, Document *doc = NULL);
84  virtual ~Residue ();
85 
99  std::map<int,int> const &GetRawFormula () const {return m_Raw;}
106  std::map<std::string, bool> const &GetSymbols () const {return m_Symbols;}
111  std::map<std::string, std::string> const &GetNames () const {return m_Names;}
115  void SetName (char const *name);
121  void AddSymbol (char const *symbol);
127  void RemoveSymbol (char const *symbol);
134  virtual void Load (xmlNodePtr node, Application *app);
142  static Residue const *GetResidue (char const *symbol, bool *ambiguous = NULL);
148  static Residue const *GetResiduebyName (char const *name);
157  static std::string const *GetFirstResidueSymbol (ResidueIterator &i);
167  static std::string const *GetNextResidueSymbol (ResidueIterator &i);
172  virtual bool operator== (G_GNUC_UNUSED Molecule const &mol) const {return false;}
173 
174 public:
179  static unsigned MaxSymbolLength;
180 
181 private:
182  std::map<int,int> m_Raw;
183  std::map<std::string, bool> m_Symbols; // boolean is true if the symbol is ambiguous
184  std::map<std::string, std::string> m_Names;
185 
189 GCU_RO_PROP (char const *, Name)
204 GCU_PROP (bool, Generic)
219 GCU_RO_PROP (Document *, Owner)
220 };
221 
222 } // namespace gcu
223 
224 #endif // GCU_RESIDUE_H