]> Git trees. - libqmvoc.git/commitdiff
really hide the private stuff
authorPino Toscano <pino@kde.org>
Wed, 4 Apr 2007 22:36:54 +0000 (22:36 +0000)
committerPino Toscano <pino@kde.org>
Wed, 4 Apr 2007 22:36:54 +0000 (22:36 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=650600

libscience/chemicaldataobject.cpp
libscience/chemicaldataobject.h

index efaf615a6934ecc6f91b744a8ca6fb08b04dcba9..c7dd2b74385a8c780aa8fd1b634f4b4bc8a5f8a3 100644 (file)
  *   Free Software Foundation, Inc.,                                       *
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.          *
  ***************************************************************************/
+
 #include <kdebug.h>
 #include "chemicaldataobject.h"
 
-//########################
-ChemicalDataObjectPrivate::ChemicalDataObjectPrivate()
+class ChemicalDataObjectPrivate : public QSharedData
 {
-}
+    public:
+        ChemicalDataObjectPrivate();
+        ~ChemicalDataObjectPrivate();
+
+        QVariant m_value;
+        QVariant m_errorValue;
+        ChemicalDataObject::BlueObelisk m_type;
+        ChemicalDataObject::BlueObeliskUnit m_unit;
+};
 
-ChemicalDataObjectPrivate::ChemicalDataObjectPrivate(const ChemicalDataObjectPrivate &other)
-: QSharedData(other)
+//########################
+ChemicalDataObjectPrivate::ChemicalDataObjectPrivate()
+: QSharedData()
 {
 }
 
@@ -36,8 +45,8 @@ ChemicalDataObjectPrivate::~ChemicalDataObjectPrivate()
 //##############
 
 ChemicalDataObject::ChemicalDataObject( const QVariant& v, BlueObelisk type, const QVariant& errorValue ) 
+  : d(new ChemicalDataObjectPrivate)
 {
-    d = new ChemicalDataObjectPrivate;
     d->m_value = v;
     d->m_errorValue = errorValue;
     d->m_type = type;
@@ -45,12 +54,27 @@ ChemicalDataObject::ChemicalDataObject( const QVariant& v, BlueObelisk type, con
 }
 
 ChemicalDataObject::ChemicalDataObject() 
+  : d(new ChemicalDataObjectPrivate)
 {
-    d = new ChemicalDataObjectPrivate;
     d->m_errorValue = QVariant();
     d->m_unit = ChemicalDataObject::noUnit;
 }
 
+ChemicalDataObject::ChemicalDataObject(const ChemicalDataObject &other)
+  : d(other.d)
+{
+}
+
+ChemicalDataObject::~ChemicalDataObject()
+{
+}
+
+ChemicalDataObject& ChemicalDataObject::operator=(const ChemicalDataObject &other)
+{
+       d = other.d;
+       return *this;
+}
+
 bool ChemicalDataObject::operator==( const int v ) const
 {
        if ( d->m_value.type() != QVariant::Int )       
@@ -83,6 +107,16 @@ bool ChemicalDataObject::operator==( const QString& v ) const
        return d->m_value.toString() == v;
 }
 
+bool ChemicalDataObject::operator==(const ChemicalDataObject &other) const
+{
+       return d == other.d;
+}
+
+bool ChemicalDataObject::operator!=(const ChemicalDataObject &other) const
+{
+       return d != other.d;
+}
+
 QString ChemicalDataObject::valueAsString() const
 {
        return d->m_value.toString();
index 7ab82ab108bcce7424021079dd46889974171411..cd32ec3cfa1604b53ec23f3aca3140937f5f4a7f 100644 (file)
@@ -118,6 +118,16 @@ class SCIENCE_EXPORT ChemicalDataObject
                                BlueObelisk type,
                                const QVariant& errorValue = QVariant(0) );
 
+               /**
+                * Copy constructor.
+                */
+               ChemicalDataObject(const ChemicalDataObject &other);
+
+               /**
+                * Destructor.
+                */
+               ~ChemicalDataObject();
+
                /**
                 * Set the data of this object to @p v
                 * @param v the value of the object
@@ -234,20 +244,14 @@ class SCIENCE_EXPORT ChemicalDataObject
                 */
                static BlueObeliskUnit unit( const QString& unitname );
                
+               ChemicalDataObject& operator=(const ChemicalDataObject &other);
+
+               bool operator==(const ChemicalDataObject &other) const;
+
+               bool operator!=(const ChemicalDataObject &other) const;
+
        private:
     QSharedDataPointer<ChemicalDataObjectPrivate> d;
 };
 
-class SCIENCE_EXPORT ChemicalDataObjectPrivate : public QSharedData
-{
-    public:
-        ChemicalDataObjectPrivate();
-        ChemicalDataObjectPrivate(const ChemicalDataObjectPrivate &other);
-        ~ChemicalDataObjectPrivate();
-
-        QVariant m_value;
-        QVariant m_errorValue;
-        ChemicalDataObject::BlueObelisk m_type;
-        ChemicalDataObject::BlueObeliskUnit m_unit;
-};
 #endif // CHEMICALDATAOBJECT_H