***************************************************************************/
#include "chemicaldataobject.h"
+#include <kdebug.h>
+
ChemicalDataObject::ChemicalDataObject( QVariant v, BlueObelisk type )
{
m_value = v;
bool ChemicalDataObject::operator==( const int v )
{
+ kdDebug() << "ChemicalDataObject::operator==() with int" << endl;
if ( m_value.type() != QVariant::Int )
return false;
return m_value.toInt() == v;
}
+bool ChemicalDataObject::operator==( const bool v )
+{
+ kdDebug() << "ChemicalDataObject::operator==() with bool" << endl;
+ if ( m_value.type() != QVariant::Bool )
+ return false;
+
+ return m_value.toBool() == v;
+}
+
+bool ChemicalDataObject::operator==( const double v )
+{
+ kdDebug() << "ChemicalDataObject::operator==() with double" << endl;
+ if ( m_value.type() != QVariant::Double )
+ return false;
+
+ return m_value.toDouble() == v;
+}
+
bool ChemicalDataObject::operator==( const QString& v )
{
+ kdDebug() << "ChemicalDataObject::operator==() with QString" << endl;
if ( m_value.type() != QVariant::String )
return false;
return m_value.toString() == v;
}
+
+ChemicalDataObject::~ChemicalDataObject()
+{}
+
radiusVDW/**< the van der Waals radius */
};
- bool operator== ( const int );
- bool operator== ( const QString& );
-
/**
* public constructor
*/
void setType( int type ){
m_type = ( BlueObelisk ) type;
}
+
+ /**
+ * Compare the value @v with the data of this object
+ */
+ bool operator== ( const int v);
+
+ /**
+ * Compare the value @v with the data of this object
+ */
+ bool operator== ( const double v);
+
+ /**
+ * Compare the value @v with the data of this object
+ */
+ bool operator== ( const bool v);
+
+ /**
+ * Compare the value @v with the data of this object
+ */
+ bool operator== ( const QString& v);
private:
QVariant m_value;
m_abundance = 0;
}
-ChemicalDataObject* Element::data(ChemicalDataObject::BlueObelisk type)
+ChemicalDataObject& Element::data(ChemicalDataObject::BlueObelisk type)
{
foreach( ChemicalDataObject*o, dataList ) {
if ( o->type() == type )
- return o;
+ return *o;
}
-
- return 0;
}
QString Element::dataAsString(ChemicalDataObject::BlueObelisk type)
*/
double meanmass();
- int x, y; //for the RegularPeriodicTableView
-
/**
* adjusts the units for the data. The user can
* for example define if Fahrenheit, Kelvin or
return m_Color;
}
+ /**
+ * add the ChemicalDataObject @p o to this Element
+ * @param o the ChemicalDataObject to be added
+ */
void addData( ChemicalDataObject*o ){
dataList.append( o );
}
- ChemicalDataObject* data( ChemicalDataObject::BlueObelisk type );
+ /**
+ * @return the ChemicalDataObject which stores the information
+ * of the type @p type
+ * @param type the type of the requested data
+ */
+ ChemicalDataObject& data( ChemicalDataObject::BlueObelisk type );
+ /**
+ * @return the requested data of the type @p type as a QString
+ */
QString dataAsString( ChemicalDataObject::BlueObelisk type );
- QList<ChemicalDataObject*> dataList;
-
+ /**
+ * @return the data of the Element
+ */
+ QList<ChemicalDataObject*> data()const{
+ return dataList;
+ }
private:
+ /**
+ * this QList stores all information about an element
+ */
+ QList<ChemicalDataObject*> dataList;
/**
* the integer num represents the number of the element
foreach( Element* e, v ){
if ( e )
{
- QList<ChemicalDataObject*> list = e->dataList;
+ QList<ChemicalDataObject*> list = e->data();
- //Give me the name of the element
- kdDebug() << "Name: " << e->dataAsString( ChemicalDataObject::name ) << endl;
+ //Test: Check if the string-comparison works
+//X if ( e->data( ChemicalDataObject::name ) == "Helium" )
+//X kdDebug() << "Mass: " << e->dataAsString( ChemicalDataObject::mass ) << endl;
-//X //give me all you have
+ //Test: Check if the double-comparison works
+//X if ( e->data( ChemicalDataObject::mass ) == 4.002602 )
+//X kdDebug() << "Correct mass found" << endl;
+
+ //Test: Give me the name of the element
+//X kdDebug() << "Name: " << e->dataAsString( ChemicalDataObject::name ) << endl;
+
+ //Test: give me all data available
//X foreach( ChemicalDataObject*o, list ){
//X if ( o )
//X kdDebug() << o->valueAsString() << endl;