85 lines
1.6 KiB
C++
85 lines
1.6 KiB
C++
#ifndef IHASPARAMS_H
|
|
#define IHASPARAMS_H
|
|
|
|
#include <Indoor/floorplan/v2/Floorplan.h>
|
|
#include <QVariant>
|
|
|
|
enum class ParamType {
|
|
INT,
|
|
FLOAT,
|
|
STRING,
|
|
FILE,
|
|
};
|
|
|
|
class ParamValue {
|
|
|
|
private:
|
|
union {
|
|
int _int;
|
|
float _float;
|
|
};
|
|
std::string _str;
|
|
|
|
public:
|
|
|
|
template <typename T> ParamValue(const T val) {
|
|
setValue(val);
|
|
}
|
|
|
|
void setValue(const std::string& val) {_str = val;}
|
|
void setValue(float val) {_float = val;}
|
|
void setValue(int val) {_int = val;}
|
|
|
|
std::string toString() const {return _str;}
|
|
float toFloat() const {return _float;}
|
|
int toInt() const {return _int;}
|
|
|
|
};
|
|
|
|
|
|
//union ParamValue {
|
|
|
|
// int _int;
|
|
// float _float;
|
|
// std::string _string;
|
|
|
|
// template <typename T> ParamValue(const T val) {
|
|
// setValue(val);
|
|
// }
|
|
|
|
// int toInt() const {return _int;}
|
|
// float toFloat() const {return _float;}
|
|
// const std::string& toString() const {return _string;}
|
|
|
|
// void setValue(const float val) {_float = val;}
|
|
// void setValue(const int val) {_int = val;}
|
|
// void setValue(const std::string& val) {_string = val;}
|
|
|
|
//};
|
|
|
|
struct Param {
|
|
std::string name;
|
|
ParamType type;
|
|
Param(const std::string& name, const ParamType type) : name(name), type(type) {;}
|
|
};
|
|
|
|
/** free parameters */
|
|
class IHasParams {
|
|
public:
|
|
|
|
/** get the number of parameters */
|
|
virtual int getNumParams() const = 0;
|
|
|
|
/** get the description of the idx-th parameter */
|
|
virtual Param getParamDesc(const int idx) const = 0;
|
|
|
|
/** get the idx-th param's value */
|
|
virtual ParamValue getParamValue(const int idx) const = 0;
|
|
|
|
/** set the idx-th param's value */
|
|
virtual void setParamValue(const int idx, const ParamValue& val) const = 0;
|
|
|
|
};
|
|
|
|
#endif // IHASPARAMS_H
|