5#define CreateHLIBase(T, LT) \
6 template<class P> class PWidgetHLIBase<P, T> { \
8 typedef std::function<T(P *)> GetterType; \
9 typedef std::function<void(P *, T)> SetterType; \
12 PWidgetHLIBase(PWidget *w, GetterType getter, SetterType setter) \
14 w->_usingHLI = true; \
15 w->_setter##LT = [setter](void *p, T v) { setter((P *)p, v); }; \
16 w->_getter##LT = [getter](void *p) { return getter((P *)p); }; \
20#define CreateInferredTemplateConstructor(className, T, constModifier) \
21 template<class P> className##HLI<P> *new_##className##HLI(const std::string &label, T (P::*getter)() constModifier, void (P::*setter)(T)) { return new className##HLI<P>(label, getter, setter); }
23#define CreateHLI(className, T) \
24 template<class P> class className##HLI final : public className, public PWidgetHLIBase<P, T> { \
26 className##HLI(const std::string &label, typename PWidgetHLIBase<P, T>::GetterType getter, typename PWidgetHLIBase<P, T>::SetterType setter) \
27 : className("", label), PWidgetHLIBase<P, T>((PWidget *)this, getter, setter) \
31 CreateInferredTemplateConstructor(className, T, ); \
32 CreateInferredTemplateConstructor(className, T, const);
47template<
class Base,
class Derived>
void AssertInheritance() { (void)
static_cast<Base *
>((Derived *)0); }
49template<
class PW,
typename T,
class P,
typename... Args>
class PWidgetHLI :
public PW {
50 typedef std::function<T(P *)> GetterType;
51 typedef std::function<void(P *, T)> SetterType;
57 PWidgetHLI(std::string label, Args... args, GetterType getter, SetterType setter) : PW(
"", args..., label)
59 printf(
"PWidgetHLI Constructor (%s)\n", label.c_str());
60 AssertInheritance<PWidget, PW>();
61 AssertInheritance<VAPoR::ParamsBase, P>();
63 this->_usingHLI =
true;
65 this->_getter = getter;
66 this->_setter = setter;
69 virtual long getParamsLong()
const override
71 static_assert(std::is_convertible<T, long>(),
"");
73 return this->_getter((P *)this->getParams());
76 virtual void _setParamsLong(
long v)
override
78 static_assert(std::is_convertible<T, long>(),
"");
80 this->_setter((P *)this->getParams(), v);
84 virtual std::string getParamsString()
const override
86 static_assert(std::is_convertible<T, std::string>(),
"");
88 return this->_getter((P *)this->getParams());
91 virtual void _setParamsString(
const std::string &v)
override
93 static_assert(std::is_convertible<T, std::string>(),
"");
95 this->_setter((P *)this->getParams(), v);
99template<
class PW,
typename T,
class P,
typename... Args>
class PWidgetHLI2 :
public PWidgetHLI<PW, T, P, Args...> {
100 using PWidgetHLI<PW, T, P, Args...>::PWidgetHLI;
103template<
class PW,
class P,
typename... Args>
class PWidgetHLI2<PW, std::string, P, Args...> :
public PWidgetHLI<PW, std::string, P, Args...> {
104 using PWidgetHLI<PW, std::string, P, Args...>::PWidgetHLI;
105 virtual std::string getParamsString()
const override {}
108template<
class PW,
typename T,
class P,
typename... Args>
typename std::enable_if<std::is_same<T, bool>::value, T>::type
class PWidgetHLI2 :
public PWidgetHLI<PW, T, P, Args...> {
109 virtual long getParamsLong()
const override {}