| 1 | //
 | 
|---|
| 2 | // formula.h --- class for calculation molecular formulae
 | 
|---|
| 3 | //
 | 
|---|
| 4 | // Copyright (C) 1997 Limit Point Systems, Inc.
 | 
|---|
| 5 | //
 | 
|---|
| 6 | // Author: Edward Seidl <seidl@janed.com>
 | 
|---|
| 7 | // Maintainer: LPS
 | 
|---|
| 8 | //
 | 
|---|
| 9 | // This file is part of the SC Toolkit.
 | 
|---|
| 10 | //
 | 
|---|
| 11 | // The SC Toolkit is free software; you can redistribute it and/or modify
 | 
|---|
| 12 | // it under the terms of the GNU Library General Public License as published by
 | 
|---|
| 13 | // the Free Software Foundation; either version 2, or (at your option)
 | 
|---|
| 14 | // any later version.
 | 
|---|
| 15 | //
 | 
|---|
| 16 | // The SC Toolkit is distributed in the hope that it will be useful,
 | 
|---|
| 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|---|
| 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
|---|
| 19 | // GNU Library General Public License for more details.
 | 
|---|
| 20 | //
 | 
|---|
| 21 | // You should have received a copy of the GNU Library General Public License
 | 
|---|
| 22 | // along with the SC Toolkit; see the file COPYING.LIB.  If not, write to
 | 
|---|
| 23 | // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 | 
|---|
| 24 | //
 | 
|---|
| 25 | 
 | 
|---|
| 26 | #ifndef _chemistry_molecule_formula_h
 | 
|---|
| 27 | #define _chemistry_molecule_formula_h
 | 
|---|
| 28 | 
 | 
|---|
| 29 | #ifdef __GNUC__
 | 
|---|
| 30 | #pragma interface
 | 
|---|
| 31 | #endif
 | 
|---|
| 32 | 
 | 
|---|
| 33 | #include <chemistry/molecule/molecule.h>
 | 
|---|
| 34 | 
 | 
|---|
| 35 | namespace sc {
 | 
|---|
| 36 | 
 | 
|---|
| 37 | /** The MolecularFormula class is used to calculate the molecular
 | 
|---|
| 38 |  formula of a Molecule.  There is only one constructor which
 | 
|---|
| 39 |  takes Ref<Molecule> as input. */
 | 
|---|
| 40 | class MolecularFormula {
 | 
|---|
| 41 |   private:
 | 
|---|
| 42 |     int natomtypes_;
 | 
|---|
| 43 |     int *Z_, *nZ_;
 | 
|---|
| 44 |     char *form_;
 | 
|---|
| 45 | 
 | 
|---|
| 46 |     void compute_atomtypes(const Molecule *m);
 | 
|---|
| 47 |     void compute_form(const Molecule *m);
 | 
|---|
| 48 |   public:
 | 
|---|
| 49 |     /// Constructors.  The argument must be nonnull.
 | 
|---|
| 50 |     MolecularFormula(const Ref<Molecule>&m);
 | 
|---|
| 51 |     MolecularFormula(const Molecule *m);
 | 
|---|
| 52 | 
 | 
|---|
| 53 |     ~MolecularFormula();
 | 
|---|
| 54 | 
 | 
|---|
| 55 |     /// Returns a null terminated string containing the molecular formula.
 | 
|---|
| 56 |     const char * formula() const;
 | 
|---|
| 57 |     /// Returns the number of atomtypes
 | 
|---|
| 58 |     int natomtypes(); 
 | 
|---|
| 59 |     /// Returns atomic number of given atomtypeindex
 | 
|---|
| 60 |     int Z(int itype); 
 | 
|---|
| 61 |     /// Returns number of atoms of given atomtypeindex
 | 
|---|
| 62 |     int nZ(int itype);
 | 
|---|
| 63 | };
 | 
|---|
| 64 | 
 | 
|---|
| 65 | }
 | 
|---|
| 66 | 
 | 
|---|
| 67 | #endif
 | 
|---|