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 {
38  return details::LabelImpl(name, get_fn);
39 }
40 
42 template<typename T, std::enable_if_t<!std::is_invocable_v<T>, int> = 0>
43 auto Label(const std::string & name, T && value)
44 {
45  return details::LabelImpl(name, details::read(std::forward<T>(value)));
46 }
47 
48 } // namespace mc_rtc::gui
mc_rtc::gui::details::LabelImpl::LabelImpl
LabelImpl()
Definition: Label.h:29
mc_rtc::gui::Label
auto Label(const std::string &name, GetT get_fn)
Definition: Label.h:36
mc_rtc::gui::details::LabelImpl
Definition: Label.h:22
mc_rtc::gui::details::read
auto read(const T &&value)
Definition: traits.h:188
elements.h
mc_rtc::gui::Elements::Label
@ Label
mc_rtc::gui::DataElement
Definition: elements.h:104
mc_rtc::gui::details::LabelImpl::LabelImpl
LabelImpl(const std::string &name, GetT get_fn)
Definition: Label.h:26
mc_rtc::gui::details::LabelImpl::type
static constexpr auto type
Definition: Label.h:24
mc_rtc::gui
Definition: Observer.h:15
mc_rtc::gui::Element::name
const std::string & name() const
Definition: elements.h:61