# gcu/residue.h

Go to the documentation of this file.

    00001 // -*- C++ -*-
    00002
    00003 /*
    00004  * Gnome Chemistry Utils
    00005  * residue.h
    00006  *
    00007  * Copyright (C) 2007-2008 Jean Bréfort <jean.brefort@normalesup.org>
    00008  *
    00009  * This program is free software; you can redistribute it and/or
    00010  * modify it under the terms of the GNU General Public License as
    00011  * published by the Free Software Foundation; either version 2 of the
    00012  * License, or (at your option) any later version.
    00013  *
    00014  * This program is distributed in the hope that it will be useful,
    00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00017  * GNU General Public License for more details.
    00018  *
    00019  * You should have received a copy of the GNU General Public License
    00020  * along with this program; if not, write to the Free Software
    00021  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
    00022  * USA
    00023  */
    00024
    00025 #ifndef GCU_RESIDUE_H
    00026 #define GCU_RESIDUE_H
    00027
    00028 #include "macros.h"
    00029 #include <libxml/parser.h>
    00030 #include <map>
    00031 #include <set>
    00032 #include <string>
    00033
    00035 namespace gcu {
    00036
    00037 class Residue;
    00038 class Molecule;
    00039 class Document;
    00040
    00044 typedef struct {
    00050         Residue *res;
    00054         bool ambiguous;
    00055 } SymbolResidue;
    00056
    00057 typedef std::map<std::string, SymbolResidue>::iterator ResidueIterator;
    00058
    00066 class Residue
    00067 {
    00068 public:
    00072         Residue ();
    00079         Residue (char const *name, Document *doc = NULL);
    00083         virtual ~Residue ();
    00084
    00098         std::map<int,int> const &GetRawFormula () const {return m_Raw;}
    00105         std::map<std::string, bool> const &GetSymbols () const {return m_Symbols;}
    00110         std::map<std::string, std::string> const &GetNames () const {return m_Names;}
    00114         void SetName (char const *name);
    00120         void AddSymbol (char const *symbol);
    00126         void RemoveSymbol (char const *symbol);
    00132         virtual void Load (xmlNodePtr node);
    00140         static Residue const *GetResidue (char const *symbol, bool *ambiguous = NULL);
    00146         static Residue const *GetResiduebyName (char const *name);
    00155         static std::string const *GetFirstResidueSymbol (ResidueIterator &i);
    00165         static std::string const *GetNextResidueSymbol (ResidueIterator &i);
    00170         virtual bool operator== (Molecule const &mol) const {return false;}
    00171
    00172 public:
    00177         static unsigned MaxSymbolLength;
    00178
    00179 private:
    00180         std::map<int,int> m_Raw;
    00181         std::map<std::string, bool> m_Symbols; // boolean is true if the symbol is ambiguous
    00182         std::map<std::string, std::string> m_Names;
    00183
    00187 GCU_RO_PROP (char const *, Name)
    00202 GCU_PROP (bool, Generic)
    00207 GCU_PROT_POINTER_PROP (Document, Document);
    00212 GCU_PROT_POINTER_PROP (Molecule, Molecule);
    00217 GCU_RO_PROP (Document *, Owner)
    00218 };
    00219
    00220 }       //      namespace gcu
    00221
    00222 #endif  //      GCU_RESIDUE_H