Test change - can I push OK?
[kdeedu-porting.git] / kalzium / src / kalziumnumerationtype.h
blobdaec9128c8b792e4ed1bd2a16ae68f5e01f919e2
1 /***************************************************************************
2 * Copyright (C) 2005, 2006 by Pino Toscano, toscano.pino@tiscali.it *
3 * *
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. *
8 * *
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. *
13 * *
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;
25 #include <QByteArray>
26 #include <QPoint>
27 #include <QRect>
28 #include <QSize>
29 #include <QStringList>
31 /**
32 * Factory for KalziumNumerationType classes.
34 * @author Pino Toscano
36 class KalziumNumerationTypeFactory
38 public:
39 /**
40 * Get the instance of this factory.
42 static KalziumNumerationTypeFactory* instance();
44 /**
45 * Returns the KalziumNumerationType with the @p id specified.
46 * It will gives 0 if none found.
48 KalziumNumerationType* build( int id ) const;
49 /**
50 * Returns the KalziumNumerationType whose name is the @p id
51 * specified.
52 * It will gives 0 if none found.
54 KalziumNumerationType* build( const QByteArray& id ) const;
56 /**
57 * Returns a list with the names of the numeration types we
58 * support.
60 QStringList numerations() const;
62 private:
63 KalziumNumerationTypeFactory();
65 QList<KalziumNumerationType*> m_numerations;
68 /**
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
76 public:
77 /**
78 * Get its instance.
80 static KalziumNumerationType* instance();
82 virtual ~KalziumNumerationType();
84 /**
85 * Returns the ID of this numeration type.
86 * Mainly used when saving/loading.
88 virtual QByteArray name() const = 0;
89 /**
90 * Returns the description of this numeration type.
91 * Used in all the visible places.
93 virtual QString description() const = 0;
95 /**
96 * Returns the @p num 'th item of this numeration type.
98 virtual QString item( const int num ) const;
99 /**
100 * Returns all the items of this numeration type.
102 virtual QStringList items() const;
104 protected:
105 KalziumNumerationType();
107 QStringList m_items;
111 * The class representing no numeration.
112 * This could look a bit weird, but this way makes quite modular even disabling
113 * the numeration.
115 * @author Pino Toscano
117 class KalziumNoneNumerationType : public KalziumNumerationType
119 public:
120 static KalziumNoneNumerationType* instance();
122 QByteArray name() const;
123 QString description() const;
125 QString item( const int num ) const;
126 QStringList items() const;
128 private:
129 KalziumNoneNumerationType();
133 * The numeration "International Union of Pure and Applied Chemistry" (IUPAC).
135 * @author Pino Toscano
137 class KalziumIUPACNumerationType : public KalziumNumerationType
139 public:
140 static KalziumIUPACNumerationType* instance();
142 QByteArray name() const;
143 QString description() const;
145 private:
146 KalziumIUPACNumerationType();
150 * The numeration "Chemical Abstract Service" (CAS).
152 * @author Pino Toscano
154 class KalziumCASNumerationType : public KalziumNumerationType
156 public:
157 static KalziumCASNumerationType* instance();
159 QByteArray name() const;
160 QString description() const;
162 private:
163 KalziumCASNumerationType();
167 * The old IUPAC numeration.
169 * @author Pino Toscano
171 class KalziumOldIUPACNumerationType : public KalziumNumerationType
173 public:
174 static KalziumOldIUPACNumerationType* instance();
176 QByteArray name() const;
177 QString description() const;
179 private:
180 KalziumOldIUPACNumerationType();
183 #endif // KALZIUMNUMERATIONTYPE_H