mc_rtc  2.16.0
Label.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015-2019 CNRS-UM LIRMM, CNRS-AIST JRL
3  */
4 
5 #pragma once
6 
7 #include <mc_rtc/gui/elements.h>
8 
9 namespace mc_rtc::gui
10 {
11 
12 namespace details
13 {
14 
21 template<typename GetT>
22 struct LabelImpl : public DataElement<GetT>
23 {
24  static constexpr auto type = Elements::Label;
25 
26  LabelImpl(const std::string & name, GetT get_fn) : DataElement<GetT>(name, get_fn) {}
27 
29  LabelImpl() {}
30 };
31 
32 } // namespace details
33 
35 template<typename GetT, std::enable_if_t<std::is_invocable_v<GetT>, int> = 0>
36 auto Label(const std::string & name, GetT get_fn)
37 { return details::LabelImpl(name, get_fn); }
38 
40 template<typename T, std::enable_if_t<!std::is_invocable_v<T>, int> = 0>
41 auto Label(const std::string & name, T && value)
42 { return details::LabelImpl(name, details::read(std::forward<T>(value))); }
43 
44 } // namespace mc_rtc::gui
std::optional< Eigen::VectorXd > value
auto read(const T &&value)
Definition: traits.h:184
Definition: Observer.h:16
auto Label(const std::string &name, GetT get_fn)
Definition: Label.h:36
Definition: elements.h:105
const std::string & name() const
Definition: elements.h:61
Definition: Label.h:23
static constexpr auto type
Definition: Label.h:24
LabelImpl(const std::string &name, GetT get_fn)
Definition: Label.h:26
LabelImpl()
Definition: Label.h:29