double Isotope::mass() const
{
- //return m_mass ? m_mass.value().toDouble() : -1.0;
- return -1.0;
+ return m_mass.value().toDouble();
}
QString Isotope::errorMargin() const
{
- //return m_mass ? m_mass.errorValue().toString() : QString();
- return QString();
+ return m_mass.errorValue().toString();
}
int Isotope::parentElementNumber() const
{
-// return m_identifier ? m_identifier.value().toInt() : -1;
- return -1;
+ return m_identifier.value().toInt();
}
QString Isotope::spin() const
{
- //return m_spin ? m_spin.value().toString() : QString();
- return QString();
+ return m_spin.value().toString();
}
QString Isotope::magmoment() const
{
- //return m_magmoment ? m_magmoment.value().toString() : QString();
- return QString();
+ return m_magmoment.value().toString();
}
QString Isotope::abundance() const
{
- //return m_abundance ? m_abundance.value().toString() : QString();
+ return m_abundance.value().toString();
return QString();
}
double Isotope::halflife() const
{
- //return m_halflife ? m_halflife.value().toDouble() : -1.0;
- return -1.0;
+ return m_halflife.value().toDouble();
}
double Isotope::ecdecay() const
{
- //return m_ecdecay ? m_ecdecay.value().toDouble() : -1.0;
- return -1.0;
+ return m_ecdecay.value().toDouble();
}
double Isotope::eclikeliness() const
{
- //return m_eclikeliness ? m_eclikeliness.value().toDouble() : -1.0;
- return -1.0;
+ return m_eclikeliness.value().toDouble();
}
double Isotope::betaplusdecay() const
{
- //return m_betaplusdecay ? m_betaplusdecay.value().toDouble() : -1.0;
- return -1.0;
+ return m_betaplusdecay.value().toDouble();
}
+
double Isotope::betapluslikeliness() const
{
- //return m_betapluslikeliness ? m_betapluslikeliness.value().toDouble() : -1.0;
- return -1.0;
+ return m_betapluslikeliness.value().toDouble();
}
+
double Isotope::betaminusdecay() const
{
- //return m_betaminusdecay ? m_betaminusdecay.value().toDouble() : -1.0;
- return -1.0;
+ return m_betaminusdecay.value().toDouble();
}
+
double Isotope::betaminuslikeliness() const
{
- //return m_betaminuslikeliness ? m_betaminuslikeliness.value().toDouble() : -1.0;
- return -1.0;
+ return m_betaminuslikeliness.value().toDouble();
}
+
double Isotope::alphadecay() const
{
- //return m_alphadecay ? m_alphadecay.value().toDouble() : -1.0;
- return -1.0;
+ return m_alphadecay.value().toDouble();
}
+
double Isotope::alphalikeliness() const
{
- //return m_alphalikeliness ? m_alphalikeliness.value().toDouble() : -1.0;
- return -1.0;
+ return m_alphalikeliness.value().toDouble();
}
+
QString Isotope::parentElementSymbol() const
{
- //return m_parentElementSymbol ? m_parentElementSymbol.value().toString() : QString();
- return QString();
+ return m_parentElementSymbol.value().toString();
}
void Isotope::setNucleons( int number )
{
- Q_UNUSED(number);
- //m_numberOfNucleons = number;
+ m_numberOfNucleons = number;
}
int Isotope::nucleons() const
{
- //return m_numberOfNucleons;
- return 0;
+ return m_numberOfNucleons;
}
Isotope::Nucleons Isotope::nucleonsAfterDecay( Decay kind )
bool IsotopeParser::startElement(const QString&, const QString &localName, const QString&, const QXmlAttributes &attrs)
{
+//X kDebug() << "IsotopeParser::startElement()" << endl;
if (localName == "isotopeList")
{
d->inElement = true;
if ( attrs.localName( i ) == "id" )
d->currentElementSymbol = attrs.value( i );
- //X kDebug() << "Symbol of the current Element: " << attrs.value( i ) << endl;
+//X kDebug() << "Symbol of the current Element: " << attrs.value( i ) << endl;
}
} else if ( d->inElement && localName == "isotope")
{
- //X kDebug() << "setting inIsotope true!" << endl;
+//X kDebug() << "setting inIsotope true!" << endl;
d->currentIsotope = new Isotope();
d->currentIsotope->addData( ChemicalDataObject( QVariant( d->currentElementSymbol ), ChemicalDataObject::symbol ) );
d->inIsotope = true;
for (int i = 0; i < attrs.length(); ++i)
{
if ( attrs.localName( i ) == "number" )
+ {
d->currentIsotope->setNucleons( attrs.value( i ).toInt() );
+//X kDebug() << attrs.value( i ).toInt() << endl;
+ }
}
} else if (d->inIsotope && localName == "scalar")
{
bool IsotopeParser::endElement( const QString&, const QString& localName, const QString& )
{
+//X kDebug() << "IsotopeParser::endElement()" << endl;
if ( localName == "isotope" )
{
d->isotopes.append(d->currentIsotope);
}
else if ( localName == "isotopeList" )
{//a new list of isotopes start...
-//X kDebug() << "setting d->inElement FALSE" << endl;
- d->inElement = false;
+//X kDebug() << "setting d->inElement FALSE" << endl;
+ d->inElement = false;
}
return true;
bool IsotopeParser::characters(const QString &ch)
{
+//X kDebug() << "IsotopeParser::characters() with ch: " << ch << endl;
d->currentDataObject = ChemicalDataObject();
ChemicalDataObject::BlueObelisk type;
QVariant value;
########### next target ###############
-set(parsertest_SRCS xmlreadingtest.cpp)
+set(elementparsertest_SRCS xmlreadingtest.cpp)
-kde4_add_executable(parsertest ${parsertest_SRCS})
+kde4_add_executable(elementparsertest ${elementparsertest_SRCS})
-target_link_libraries(parsertest science)
+target_link_libraries(elementparsertest science)
+
+########### next target ###############
+
+set(isotopeparsertest_SRCS isotopereadingtest.cpp)
+
+kde4_add_executable(isotopeparsertest ${isotopeparsertest_SRCS})
+
+target_link_libraries(isotopeparsertest science)
endif(KDE4_BUILD_TESTS)
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2005, 2006 by Carsten Niehaus <cniehaus@kde.org> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#include "isotopeparser.h"
+#include "isotope.h"
+#include <kdebug.h>
+#include <iostream>
+
+int main(int argc, char *argv[])
+{
+ if (argc < 2 || argc > 2) {
+ std::cout << "Usage: isotopes <XML_FILE>\n";
+ return 1;
+ }
+
+ IsotopeParser * parser = new IsotopeParser();
+ QFile xmlFile(argv[1]);
+
+ QXmlInputSource source(&xmlFile);
+ QXmlSimpleReader reader;
+
+ reader.setContentHandler(parser);
+ reader.parse(source);
+
+ QList<Isotope*> v = parser->getIsotopes();
+
+ kDebug() << "Found " << v.count() << " isotopes." << endl;;
+
+ kDebug() << "As a test I am now issuing all isotopes with 50 nuclueons: " << endl;
+
+ foreach( Isotope* i, v ){
+ if ( i )
+ {
+ if (i->nucleons() == 50 )
+ kDebug() << " Isotope of " << i->parentElementSymbol() << " with a mass of " << i->mass() << endl;
+ }
+ }
+
+ delete parser;
+ qDeleteAll(v);
+
+ return 0;
+}