diff --git a/src/FactSystem/Fact.cc b/src/FactSystem/Fact.cc index 6ae59e82bdff86d98cf1582d3af11ac005e93a4f..d43488fa5959eb5ddc311661098ba6b11c03c3fa 100644 --- a/src/FactSystem/Fact.cc +++ b/src/FactSystem/Fact.cc @@ -28,25 +28,49 @@ #include -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) diff --git a/src/FactSystem/Fact.h b/src/FactSystem/Fact.h index b12647ad7232749ea8372abf0516732f901c9a88..90be94d4a41d842b045a899633ff8adbdda4c844 100644 --- a/src/FactSystem/Fact.h +++ b/src/FactSystem/Fact.h @@ -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) diff --git a/src/FactSystem/FactMetaData.cc b/src/FactSystem/FactMetaData.cc index 33377ac0897521c4d900ca4a82149a0016475fed..3d63c41c944272fbca43957f0ff143ce1d7462bd 100644 --- a/src/FactSystem/FactMetaData.cc +++ b/src/FactSystem/FactMetaData.cc @@ -32,6 +32,20 @@ #include +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) { diff --git a/src/FactSystem/FactMetaData.h b/src/FactSystem/FactMetaData.h index 2afcdf1981545d4d0941f5701d4741a65a5218d2..8ad7c11182404e87f6667791b2257fec12fe5626 100644 --- a/src/FactSystem/FactMetaData.h +++ b/src/FactSystem/FactMetaData.h @@ -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; }