50 lines
1.1 KiB
C++
50 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include "common.h"
|
|
|
|
/// <summary>
|
|
/// Êýֵת»»³éÏó½Ó¿Ú
|
|
/// </summary>
|
|
class ValueConvert : public Serializable {
|
|
public:
|
|
virtual ~ValueConvert() = default;
|
|
|
|
virtual QString name() const = 0;
|
|
virtual DataType inType() const = 0;
|
|
virtual DataType outType() const = 0;
|
|
virtual QVariant convert(const QVariant& value) const = 0;
|
|
};
|
|
|
|
namespace convert {
|
|
class AbstractValueConvert : public ValueConvert {
|
|
private:
|
|
QString typename_store;
|
|
DataType _in_type, _out_type;
|
|
|
|
public:
|
|
AbstractValueConvert(const QString& nm, DataType in, DataType out);
|
|
|
|
QString name() const override;
|
|
DataType inType() const override;
|
|
DataType outType() const override;
|
|
|
|
void loadFrom(std::shared_ptr<TranslateBasic> core, const QJsonObject& obj) override;
|
|
void saveTo(QJsonObject& obj) const override;
|
|
};
|
|
|
|
|
|
class DoubleWithLSB : public AbstractValueConvert {
|
|
private:
|
|
double _lsb_value;
|
|
|
|
public:
|
|
DoubleWithLSB();
|
|
|
|
void setLSB(double lsbv);
|
|
double getLSB() const;
|
|
|
|
QVariant convert(const QVariant& value) const override;
|
|
std::shared_ptr<Serializable> newDefault() const override;
|
|
};
|
|
}
|