The Gnome Chemistry Utils  0.14.0
gcu/molecule.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*
4  * Gnome Chemistry Utils
5  * libs/gcu/molecule.h
6  *
7  * Copyright (C) 2001-2012 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_MOLECULE_H
26 #define GCU_MOLECULE_H
27 
28 #include "object.h"
29 #include "structs.h"
30 
32 namespace gcu {
33 
34 class Atom;
35 class Bond;
36 class Chain;
37 class Cycle;
38 class Formula;
39 
43 class Molecule: public Object
44 {
45 friend class Chain;
46 public:
55  Molecule (TypeId Type = MoleculeType, ContentType ct = ContentType3D);
64  Molecule (Atom* pAtom, ContentType ct = ContentType3D);
68  virtual ~Molecule ();
69 
75  void AddChild (Object* object);
81  virtual void AddAtom (Atom* pAtom);
87  virtual void AddBond (Bond* pBond);
93  virtual void Remove (gcu::Object* pObject);
99  void UpdateCycles (Bond* pBond);
103  void UpdateCycles ();
109  bool operator== (Molecule const& molecule) const;
113  virtual unsigned GetAtomsNumber () const {return m_Atoms.size ();}
124  static Molecule *MoleculeFromFormula (Document *Doc, Formula const &formula, bool add_pseudo = true);
125 
129  void Clear ();
135  Atom const *GetFirstAtom (std::list<Atom*>::const_iterator &i) const;
136  Atom *GetFirstAtom (std::list<Atom*>::iterator &i);
142  Atom const *GetNextAtom (std::list<Atom*>::const_iterator &i) const;
143  Atom *GetNextAtom (std::list<Atom*>::iterator &i);
149  Bond const *GetFirstBond (std::list<Bond*>::const_iterator &i) const;
155  Bond const *GetNextBond(std::list<Bond*>::const_iterator &i) const;
166  void SetName (char const *name, char const *convention);
172  char const *GetName (char const *convention = NULL);
176  std::string Name ();
177 
181  void ResetIndentifiers ();
182 
186  std::string const &GetCML ();
187 
191  void ClearCycles ();
192 
196  std::string const &GetInChI ();
197 
201  std::string const &GetInChIKey ();
202 
206  std::string const &GetSMILES ();
210  virtual std::string GetRawFormula () const;
211 
212 protected:
216  std::list<Cycle*> m_Cycles;
220  std::list<Chain*> m_Chains;
224  std::list<Atom*> m_Atoms;
228  std::list<Bond*> m_Bonds;
229 
230 private:
231  std::map <std::string, std::string> m_Names;
232  std::string m_CML;
233  std::string m_InChI;
234  std::string m_InChIKey;
235  std::string m_SMILES;
236  ContentType m_Content;
237 };
238 
239 } // namespace gcu
240 
241 #endif // GCU_MOLECULE_H