The Gnome Chemistry Utils 0.13.3
gcu/molecule.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 /* 
00004  * Gnome Chemistry Utils
00005  * libs/gcu/molecule.h 
00006  *
00007  * Copyright (C) 2001-2011 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_MOLECULE_H
00026 #define GCU_MOLECULE_H
00027 
00028 #include "object.h"
00029 #include "structs.h"
00030 
00032 namespace gcu {
00033 
00034 class Atom;
00035 class Bond;
00036 class Chain;
00037 class Cycle;
00038 class Formula;
00039 
00043 class Molecule: public Object
00044 {
00045 friend class Chain;
00046 public:
00053         Molecule (TypeId Type = MoleculeType, ContentType ct = ContentType3D);
00060         Molecule (Atom* pAtom, ContentType ct = ContentType3D);
00064         virtual ~Molecule ();
00065 
00071         void AddChild (Object* object);
00077         virtual void AddAtom (Atom* pAtom);
00083         virtual void AddBond (Bond* pBond);
00089         virtual void Remove (gcu::Object* pObject);
00095         void UpdateCycles (Bond* pBond);
00099         void UpdateCycles ();
00105         bool operator== (Molecule const& molecule) const;
00109         virtual unsigned GetAtomsNumber () const {return m_Atoms.size ();}
00120         static Molecule *MoleculeFromFormula (Document *Doc, Formula const &formula, bool add_pseudo = true);
00121 
00125         void Clear ();
00131         Atom const *GetFirstAtom (std::list<Atom*>::const_iterator &i) const;
00137         Atom const *GetNextAtom (std::list<Atom*>::const_iterator &i) const;
00143         Bond const *GetFirstBond (std::list<Bond*>::const_iterator &i) const;
00149         Bond const *GetNextBond(std::list<Bond*>::const_iterator &i) const;
00160         void SetName (char const *name, char const *convention);
00166         char const *GetName (char const *convention = NULL);
00170         std::string Name ();
00171 
00172         void ResetIndentifiers ();
00173         std::string const &GetCML ();
00177         std::string const &GetInChI ();
00178         std::string const &GetInChIKey ();
00179         std::string const &GetSMILES ();
00180 
00181 protected:
00185         std::list<Cycle*> m_Cycles;
00189         std::list<Chain*> m_Chains;
00193         std::list<Atom*> m_Atoms;
00197         std::list<Bond*> m_Bonds;
00198 
00199 private:
00200         std::map <std::string, std::string> m_Names;
00201         std::string m_CML;
00202         std::string m_InChI;
00203         std::string m_InChIKey;
00204         std::string m_SMILES;
00205         ContentType m_Content;
00206 };
00207 
00208 }       //      namespace gcu
00209 
00210 #endif  //      GCU_MOLECULE_H