1 /***************************************************************************
2 * Copyright (C) 2005, 2006 by Pino Toscano, toscano.pino@tiscali.it *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
20 #ifndef KALZIUMNUMERATIONTYPE_H
21 #define KALZIUMNUMERATIONTYPE_H
23 class KalziumNumerationType
;
29 #include <QStringList>
32 * Factory for KalziumNumerationType classes.
34 * @author Pino Toscano
36 class KalziumNumerationTypeFactory
40 * Get the instance of this factory.
42 static KalziumNumerationTypeFactory
* instance();
45 * Returns the KalziumNumerationType with the @p id specified.
46 * It will gives 0 if none found.
48 KalziumNumerationType
* build( int id
) const;
50 * Returns the KalziumNumerationType whose name is the @p id
52 * It will gives 0 if none found.
54 KalziumNumerationType
* build( const QByteArray
& id
) const;
57 * Returns a list with the names of the numeration types we
60 QStringList
numerations() const;
63 KalziumNumerationTypeFactory();
65 QList
<KalziumNumerationType
*> m_numerations
;
69 * Base class for a numeration type.
70 * It's quite simple, as a numeration doesn't have many data to represent.
72 * @author Pino Toscano
74 class KalziumNumerationType
80 static KalziumNumerationType
* instance();
82 virtual ~KalziumNumerationType();
85 * Returns the ID of this numeration type.
86 * Mainly used when saving/loading.
88 virtual QByteArray
name() const = 0;
90 * Returns the description of this numeration type.
91 * Used in all the visible places.
93 virtual QString
description() const = 0;
96 * Returns the @p num 'th item of this numeration type.
98 virtual QString
item( const int num
) const;
100 * Returns all the items of this numeration type.
102 virtual QStringList
items() const;
105 KalziumNumerationType();
111 * The class representing no numeration.
112 * This could look a bit weird, but this way makes quite modular even disabling
115 * @author Pino Toscano
117 class KalziumNoneNumerationType
: public KalziumNumerationType
120 static KalziumNoneNumerationType
* instance();
122 QByteArray
name() const;
123 QString
description() const;
125 QString
item( const int num
) const;
126 QStringList
items() const;
129 KalziumNoneNumerationType();
133 * The numeration "International Union of Pure and Applied Chemistry" (IUPAC).
135 * @author Pino Toscano
137 class KalziumIUPACNumerationType
: public KalziumNumerationType
140 static KalziumIUPACNumerationType
* instance();
142 QByteArray
name() const;
143 QString
description() const;
146 KalziumIUPACNumerationType();
150 * The numeration "Chemical Abstract Service" (CAS).
152 * @author Pino Toscano
154 class KalziumCASNumerationType
: public KalziumNumerationType
157 static KalziumCASNumerationType
* instance();
159 QByteArray
name() const;
160 QString
description() const;
163 KalziumCASNumerationType();
167 * The old IUPAC numeration.
169 * @author Pino Toscano
171 class KalziumOldIUPACNumerationType
: public KalziumNumerationType
174 static KalziumOldIUPACNumerationType
* instance();
176 QByteArray
name() const;
177 QString
description() const;
180 KalziumOldIUPACNumerationType();
183 #endif // KALZIUMNUMERATIONTYPE_H