Commit d11aef13 authored by Don Gagne's avatar Don Gagne

Support copy constructor

parent f323f850
......@@ -28,25 +28,49 @@
#include <QtQml>
Fact::Fact(void) :
_componentId(-1),
_value(0),
_type(FactMetaData::valueTypeInt32),
_metaData(NULL)
Fact::Fact(QObject* parent)
: QObject(parent)
, _componentId(-1)
, _value(0)
, _type(FactMetaData::valueTypeInt32)
, _metaData(NULL)
{
FactMetaData* metaData = new FactMetaData(_type, this);
setMetaData(metaData);
}
Fact::Fact(int componentId, QString name, FactMetaData::ValueType_t type, QObject* parent) :
QObject(parent),
_name(name),
_componentId(componentId),
_value(0),
_type(type),
_metaData(NULL)
Fact::Fact(int componentId, QString name, FactMetaData::ValueType_t type, QObject* parent)
: QObject(parent)
, _name(name)
, _componentId(componentId)
, _value(0)
, _type(type)
, _metaData(NULL)
{
FactMetaData* metaData = new FactMetaData(_type, this);
setMetaData(metaData);
}
Fact::Fact(const Fact& other, QObject* parent)
: QObject(parent)
{
*this = other;
}
const Fact& Fact::operator=(const Fact& other)
{
_name = other._name;
_componentId = other._componentId;
_value = other._value;
_type = other._type;
if (_metaData && other._metaData) {
*_metaData = *other._metaData;
} else {
_metaData = NULL;
}
return *this;
}
void Fact::forceSetValue(const QVariant& value)
......
......@@ -40,9 +40,12 @@ class Fact : public QObject
Q_OBJECT
public:
Fact(void);
Fact(QObject* parent = NULL);
Fact(int componentId, QString name, FactMetaData::ValueType_t type, QObject* parent = NULL);
Fact(const Fact& other, QObject* parent = NULL);
const Fact& operator=(const Fact& other);
Q_PROPERTY(int componentId READ componentId CONSTANT)
Q_PROPERTY(QString name READ name CONSTANT)
Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged USER true)
......
......@@ -32,6 +32,20 @@
#include <limits>
FactMetaData::FactMetaData(QObject* parent) :
QObject(parent),
_group("*Default Group"),
_type(valueTypeInt32),
_defaultValue(0),
_defaultValueAvailable(false),
_min(_minForType()),
_max(_maxForType()),
_minIsDefaultForType(true),
_maxIsDefaultForType(true)
{
}
FactMetaData::FactMetaData(ValueType_t type, QObject* parent) :
QObject(parent),
_group("*Default Group"),
......@@ -46,6 +60,26 @@ FactMetaData::FactMetaData(ValueType_t type, QObject* parent) :
}
FactMetaData::FactMetaData(const FactMetaData& other, QObject* parent)
: QObject(parent)
{
*this = other;
}
const FactMetaData& FactMetaData::operator=(const FactMetaData& other)
{
_group = other._group;
_type = other._type;
_defaultValue = other._defaultValue;
_defaultValueAvailable = other._defaultValueAvailable;
_min = other._min;
_max = other._max;
_minIsDefaultForType = other._minIsDefaultForType;
_maxIsDefaultForType = other._maxIsDefaultForType;
return *this;
}
QVariant FactMetaData::defaultValue(void)
{
if (_defaultValueAvailable) {
......
......@@ -52,7 +52,11 @@ public:
valueTypeDouble
} ValueType_t;
FactMetaData(QObject* parent = NULL);
FactMetaData(ValueType_t type, QObject* parent = NULL);
FactMetaData(const FactMetaData& other, QObject* parent = NULL);
const FactMetaData& operator=(const FactMetaData& other);
// Property accessors
QString name(void) { return _name; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment