~ubuntu-branches/ubuntu/precise/kalzium/precise

« back to all changes in this revision

Viewing changes to src/kalziumnumerationtype.h

  • Committer: Bazaar Package Importer
  • Author(s): Philip Muškovac
  • Date: 2011-07-03 12:28:58 UTC
  • Revision ID: james.westby@ubuntu.com-20110703122858-q1yyxncs89e4w0hs
Tags: upstream-4.6.90+repack
Import upstream version 4.6.90+repack

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 ***************************************************************************/
 
19
 
 
20
#ifndef KALZIUMNUMERATIONTYPE_H
 
21
#define KALZIUMNUMERATIONTYPE_H
 
22
 
 
23
class KalziumNumerationType;
 
24
 
 
25
#include <QByteArray>
 
26
#include <QStringList>
 
27
 
 
28
/**
 
29
 * Factory for KalziumNumerationType classes.
 
30
 *
 
31
 * @author Pino Toscano
 
32
 */
 
33
class KalziumNumerationTypeFactory
 
34
  {
 
35
  public:
 
36
    /**
 
37
     * Get the instance of this factory.
 
38
     */
 
39
    static KalziumNumerationTypeFactory* instance();
 
40
 
 
41
    /**
 
42
     * Returns the KalziumNumerationType with the @p id specified.
 
43
     * It will gives 0 if none found.
 
44
     */
 
45
    KalziumNumerationType* build ( int id ) const;
 
46
    /**
 
47
     * Returns the KalziumNumerationType whose name is the @p id
 
48
     * specified.
 
49
     * It will gives 0 if none found.
 
50
     */
 
51
    KalziumNumerationType* build ( const QByteArray& id ) const;
 
52
 
 
53
    /**
 
54
     * Returns a list with the names of the numeration types we
 
55
     * support.
 
56
     */
 
57
    QStringList numerations() const;
 
58
 
 
59
  private:
 
60
    KalziumNumerationTypeFactory();
 
61
 
 
62
    QList<KalziumNumerationType*> m_numerations;
 
63
  };
 
64
 
 
65
/**
 
66
 * Base class for a numeration type.
 
67
 * It's quite simple, as a numeration doesn't have many data to represent.
 
68
 *
 
69
 * @author Pino Toscano
 
70
 */
 
71
class KalziumNumerationType
 
72
  {
 
73
  public:
 
74
    /**
 
75
     * Get its instance.
 
76
     */
 
77
    static KalziumNumerationType* instance();
 
78
 
 
79
    virtual ~KalziumNumerationType();
 
80
 
 
81
    /**
 
82
     * Returns the ID of this numeration type.
 
83
     * Mainly used when saving/loading.
 
84
     */
 
85
    virtual QByteArray name() const = 0;
 
86
    /**
 
87
     * Returns the description of this numeration type.
 
88
     * Used in all the visible places.
 
89
     */
 
90
    virtual QString description() const = 0;
 
91
 
 
92
    /**
 
93
     * Returns the @p num 'th item of this numeration type.
 
94
     */
 
95
    virtual QString item ( const int num ) const;
 
96
    /**
 
97
     * Returns all the items of this numeration type.
 
98
     */
 
99
    virtual QStringList items() const;
 
100
 
 
101
  protected:
 
102
    KalziumNumerationType();
 
103
 
 
104
    QStringList m_items;
 
105
  };
 
106
 
 
107
/**
 
108
 * The class representing no numeration.
 
109
 * This could look a bit weird, but this way makes quite modular even disabling
 
110
 * the numeration.
 
111
 *
 
112
 * @author Pino Toscano
 
113
 */
 
114
class KalziumNoneNumerationType : public KalziumNumerationType
 
115
  {
 
116
  public:
 
117
    static KalziumNoneNumerationType* instance();
 
118
 
 
119
    QByteArray name() const;
 
120
    QString description() const;
 
121
 
 
122
    QString item ( const int num ) const;
 
123
    QStringList items() const;
 
124
 
 
125
  private:
 
126
    KalziumNoneNumerationType();
 
127
  };
 
128
 
 
129
/**
 
130
 * The numeration "International Union of Pure and Applied Chemistry" (IUPAC).
 
131
 *
 
132
 * @author Pino Toscano
 
133
 */
 
134
class KalziumIUPACNumerationType : public KalziumNumerationType
 
135
  {
 
136
  public:
 
137
    static KalziumIUPACNumerationType* instance();
 
138
 
 
139
    QByteArray name() const;
 
140
    QString description() const;
 
141
 
 
142
  private:
 
143
    KalziumIUPACNumerationType();
 
144
  };
 
145
 
 
146
/**
 
147
 * The numeration "Chemical Abstract Service" (CAS).
 
148
 *
 
149
 * @author Pino Toscano
 
150
 */
 
151
class KalziumCASNumerationType : public KalziumNumerationType
 
152
  {
 
153
  public:
 
154
    static KalziumCASNumerationType* instance();
 
155
 
 
156
    QByteArray name() const;
 
157
    QString description() const;
 
158
 
 
159
  private:
 
160
    KalziumCASNumerationType();
 
161
  };
 
162
 
 
163
/**
 
164
 * The old IUPAC numeration.
 
165
 *
 
166
 * @author Pino Toscano
 
167
 */
 
168
class KalziumOldIUPACNumerationType : public KalziumNumerationType
 
169
  {
 
170
  public:
 
171
    static KalziumOldIUPACNumerationType* instance();
 
172
 
 
173
    QByteArray name() const;
 
174
    QString description() const;
 
175
 
 
176
  private:
 
177
    KalziumOldIUPACNumerationType();
 
178
  };
 
179
 
 
180
#endif // KALZIUMNUMERATIONTYPE_H