File indexing completed on 2024-04-21 03:41:35

0001 /*
0002     SPDX-FileCopyrightText: 2005 Carsten Niehaus <cniehaus@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef CHEMICALDATAOBJECT_H
0008 #define CHEMICALDATAOBJECT_H
0009 
0010 #include <QSharedData>
0011 #include <QSharedDataPointer>
0012 #include <QVariant>
0013 
0014 #include "science_export.h"
0015 
0016 class ChemicalDataObjectPrivate;
0017 /**
0018  * A ChemicalDataObject is an object which contains information about
0019  * a chemical element. This can for example be a boiling point. The information
0020  * is stored in a QVariant.
0021  * This class supports the CML-format defined by the BlueObelisk-Project.
0022  *
0023  * @author Carsten Niehaus <cniehaus@kde.org>
0024  */
0025 class SCIENCE_EXPORT ChemicalDataObject
0026 {
0027 public:
0028     /**
0029      * The BlueObelisk-project defines in their XML file the dataset
0030      * with the names of the enum plus "bo:". So for symbol
0031      * it is "bo:symbol". To avoid confusion I will choose the very
0032      * same naming
0033      */
0034     enum BlueObelisk {
0035         atomicNumber = 0 /**< The atomic number of the element */,
0036         symbol /**< the symbol of the element */,
0037         name /**< The IUPAC name of the element */,
0038         mass /**< # IUPAC Official Masses */,
0039         exactMass /**< exact masses of the most common isotopes for each element */,
0040         ionization /**< First inizationenergy */,
0041         electronAffinity /**< the electron affinity of the element */,
0042         electronegativityPauling /**< the electronegativity in the definition of Pauling*/,
0043         radiusCovalent /**< the covalent radius */,
0044         radiusVDW /**< the van der Waals radius */,
0045         meltingpoint /**< the meltingpoint */,
0046         boilingpoint /**< the boilingpoint */,
0047         periodTableBlock /**< the block of the element */,
0048         family /**< "Noblegas" "Non-Metal" "Rare_Earth" "Alkaline_Earth" "Alkali_Earth" "Transition" "Other_Metal" "Metalloids" "Halogene" */,
0049         acidicbehaviour /**< 0 means acidic, 1 means basic, 2 means neutral, 3 means amphoteric*/,
0050         crystalstructure /**< own, bcc, hdp, ccp, hcp, fcc, d, sc, tet, rh, or, mono*/,
0051         electronicConfiguration /**< the electronic configuration, for example 1s2 for He*/,
0052         group /**< This is a value between 1 and 8*/,
0053         nameOrigin /**< the origin of the name */,
0054         orbit /**< the quantumorbit of the element */,
0055         period /**< the period of the element */,
0056         date /**< date of discovery of the element. When 0, the element has been known in ancient times. When the value is -1 the element has not yet been
0057                 officially recognized by the IUPAC */
0058         ,
0059         discoverers /** The name of the discoverers, separated by semicolomns */,
0060         relativeAbundance /** The abundance, relative to 100 */,
0061         spin /**< The spin */,
0062         magneticMoment /**< The magnetic dipole moment */,
0063         halfLife /**< The halflife */,
0064         alphaDecayLikeliness /**< The percentage of alphadecay */,
0065         alphaDecay /**< The decayenergy of alphadecay in MeV */,
0066         alphabetaminusDecayLikeliness /**< The percentage of alphadecay */,
0067         alphabetaminusDecay /**< The decayenergy of alphadecay in MeV */,
0068         betaplusDecayLikeliness /**< The percentage of betaplusdecay */,
0069         betaplusDecay /**< The decayenergy of betaplusdecay in MeV */,
0070         twobetaplusDecayLikeliness,
0071         twobetaplusDecay,
0072         betaplusprotonDecayLikeliness /**< The percentage of betaplusdecay */,
0073         betaplusprotonDecay /**< The decayenergy of betaplusdecay in MeV */,
0074         betaplustwoprotonDecayLikeliness,
0075         betaplustwoprotonDecay,
0076         betaplusalphaDecayLikeliness /**< The percentage of betaplusdecay */,
0077         betaplusalphaDecay /**< The decayenergy of betaplusdecay in MeV */,
0078         betaplustwoalphaDecayLikeliness,
0079         betaplustwoalphaDecay,
0080         betaplusthreealphaDecayLikeliness,
0081         betaplusthreealphaDecay,
0082         betaminusDecayLikeliness /**< The percentage of betaminusdecay */,
0083         betaminusDecay /**< The decayenergy of betaminusdecay in MeV */,
0084         twobetaminusDecayLikeliness,
0085         twobetaminusDecay,
0086         betaminusneutronDecayLikeliness /**< The percentage of betaminusdecay */,
0087         betaminusneutronDecay /**< The decayenergy of betaminusdecay in MeV */,
0088         betaminustwoneutronDecayLikeliness,
0089         betaminustwoneutronDecay,
0090         betaminusthreeneutronDecayLikeliness,
0091         betaminusthreeneutronDecay,
0092         betaminusfourneutronDecayLikeliness,
0093         betaminusfourneutronDecay,
0094         betaminusfissionDecayLikeliness /**< The percentage of betaminusdecay */,
0095         betaminusfissionDecay /**< The decayenergy of betaminusdecay in MeV */,
0096         betaminusalphaDecayLikeliness /**< The percentage of betaminusdecay */,
0097         betaminusalphaDecay /**< The decayenergy of betaminusdecay in MeV */,
0098         betaminustwoalphaDecayLikeliness,
0099         betaminustwoalphaDecay,
0100         betaminusthreealphaDecayLikeliness,
0101         betaminusthreealphaDecay,
0102         betaminusalphaneutronDecay,
0103         betaminusalphaneutronDecayLikeliness,
0104         ecDecayLikeliness /**< The percentage of ecdecay */,
0105         ecDecay /**< The decayenergy of ecminusdecay in MeV */,
0106         twoecDecayLikeliness,
0107         twoecDecay,
0108         ecalphaDecayLikeliness,
0109         ecalphaDecay,
0110         ecalphaprotonDecayLikeliness,
0111         ecalphaprotonDecay,
0112         ecprotonDecayLikeliness,
0113         ecprotonDecay,
0114         ectwoprotonDecayLikeliness,
0115         ectwoprotonDecay,
0116         ecthreeprotonDecayLikeliness,
0117         ecthreeprotonDecay,
0118         protonDecayLikeliness /**< The percentage of protondecay */,
0119         protonDecay /**< The decayenergy of protonminusdecay in MeV */,
0120         twoprotonDecayLikeliness,
0121         twoprotonDecay,
0122         protonalphaDecayLikeliness /**< The percentage of protondecay */,
0123         protonalphaDecay /**< The decayenergy of protonminusdecay in MeV */,
0124         neutronDecayLikeliness /**< The percentage of neutrondecay */,
0125         neutronDecay /**< The decayenergy of neutronminusdecay in MeV */,
0126         twoneutronDecayLikeliness,
0127         twoneutronDecay,
0128         spontfissionDecayLikeliness,
0129         spontfissionDecay,
0130         dangerSymbol /**< the danger symbols are the dangers associated with an element, for example Xn,T+ */,
0131         RPhrase /**< */,
0132         SPhrase /**< */,
0133         discoveryCountry,
0134         oxidation /**< Oxidation states*/
0135     };
0136 
0137     /**
0138      * Constructor.
0139      */
0140     ChemicalDataObject();
0141 
0142     /**
0143      * Constructor.
0144      * @param v the data of the object
0145      * @param type the type of the data
0146      * @param errorValue the error margin of the value @p v
0147      *
0148      * @see errorValue()
0149      */
0150     ChemicalDataObject(const QVariant &v, BlueObelisk type, const QVariant &errorValue = QVariant(0));
0151 
0152     /**
0153      * Copy constructor.
0154      */
0155     ChemicalDataObject(const ChemicalDataObject &other);
0156 
0157     /**
0158      * Destructor.
0159      */
0160     ~ChemicalDataObject();
0161 
0162     /**
0163      * Set the data of this object to @p v
0164      * @param v the value of the object
0165      */
0166     void setData(const QVariant &v);
0167 
0168     /**
0169      * Set the error value of this object to @p v.
0170      * The error has to have the same unit as the value.
0171      * @param v the value of the object
0172      */
0173     void setErrorValue(const QVariant &v);
0174 
0175     /**
0176      * Every ChemicalDataObject contains one data. For example a
0177      * integer value which represents the boiling point. This method
0178      * returns the value as a QString.
0179      *
0180      * For bool, the returned string will be "false" or "true"
0181      * For a QString, the QString will be returned
0182      * For a int or double, the value will be returned as a QString
0183      *
0184      * @return the value as a QString
0185      */
0186     QString valueAsString() const;
0187 
0188     /**
0189      * Every ChemicalDataObject contains one data. For example a
0190      * integer value which represents the boiling point. This method
0191      * returns the value as a QVariant.
0192      *
0193      * @return the value as a QVariant
0194      */
0195     QVariant value() const;
0196 
0197     /**
0198      * @return the error margin of the object
0199      */
0200     QVariant errorValue() const;
0201 
0202     /**
0203      * @return the type of dataset of this object
0204      */
0205     BlueObelisk type() const;
0206 
0207     /**
0208      * @param type the type of this object
0209      */
0210     void setType(BlueObelisk type);
0211 
0212     /**
0213      * @overload
0214      */
0215     void setType(int type);
0216 
0217     /**
0218      * Compare the value @p v with the data of this object
0219      */
0220     bool operator==(const int v) const;
0221 
0222     /**
0223      * Compare the value @p v with the data of this object
0224      */
0225     bool operator==(const double v) const;
0226 
0227     /**
0228      * Compare the value @p v with the data of this object
0229      */
0230     bool operator==(const bool v) const;
0231 
0232     /**
0233      * Compare the value @p v with the data of this object
0234      */
0235     bool operator==(const QString &v) const;
0236 
0237     /**
0238      * @return the unit of the object as a QString. For example kelvin
0239      * will be returned as "bo:kelvin"
0240      */
0241     QString unitAsString() const;
0242 
0243     /**
0244      * @return the unit of the object
0245      */
0246     int unit() const;
0247 
0248     /**
0249      * set the unit of this object to @p unit
0250      * @param unit the BlueObeliskUnit for this object
0251      */
0252     void setUnit(int unit);
0253 
0254     ChemicalDataObject &operator=(const ChemicalDataObject &other);
0255 
0256     bool operator==(const ChemicalDataObject &other) const;
0257 
0258     bool operator!=(const ChemicalDataObject &other) const;
0259 
0260 private:
0261     QSharedDataPointer<ChemicalDataObjectPrivate> d;
0262 };
0263 
0264 #endif // CHEMICALDATAOBJECT_H