This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
IndoorMap/mapview/model/IHasParams.h
kazu 92e279aefc added option for underlay opacity change
adjusted interface [removed invalid const]
2017-03-20 15:25:54 +01:00

112 lines
2.3 KiB
C++

#ifndef IHASPARAMS_H
#define IHASPARAMS_H
#include <Indoor/floorplan/v2/Floorplan.h>
#include <Indoor/geo/Point2.h>
#include <Indoor/geo/Point3.h>
enum class ParamType {
NOT_AVAILABLE,
BOOL,
INT,
FLOAT,
STRING,
FILE,
POINT2,
POINT3,
};
class ParamValue {
private:
union {
bool _bool;
int _int;
float _float;
float _arr[3];
};
std::string _str;
public:
template <typename T> ParamValue(const T val) {
setValue(val);
}
void setValue(const std::string& val) {_str = val;}
void setValue(const float val) {_float = val;}
void setValue(const int val) {_int = val;}
void setValue(const bool val) {_bool = val;}
void setValue(const Point2 p) {_arr[0] = p.x; _arr[1] = p.y;}
void setValue(const Point3 p) {_arr[0] = p.x; _arr[1] = p.y; _arr[2] = p.z;}
Point2 toPoint2() const {return Point2(_arr[0], _arr[1]);}
Point3 toPoint3() const {return Point3(_arr[0], _arr[1], _arr[2]);}
std::string toString() const {return _str;}
float toFloat() const {return _float;}
int toInt() const {return _int;}
bool toBool() const {return _bool;}
};
//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 {
/** parameter name */
std::string name;
/** parameter type */
ParamType type;
/** read-only parameter? */
bool readOnly;
/** ctor */
Param(const std::string& name, const ParamType type, const bool readOnly = false) : name(name), type(type), readOnly(readOnly) {;}
/** special parameter */
static Param getNA() { return Param("", ParamType::NOT_AVAILABLE); }
};
/** 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) = 0;
};
#endif // IHASPARAMS_H