Rotation.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 
8 #include <mc_rtc/gui/elements.h>
9 #include <mc_rtc/gui/types.h>
10 
11 namespace mc_rtc::gui
12 {
13 
14 namespace details
15 {
16 
27 template<typename GetT, typename SetT = std::nullptr_t>
28 struct RotationImpl : public CommonInputImpl<GetT, SetT>
29 {
30  static constexpr auto type = Elements::Rotation;
31 
32  RotationImpl(const std::string & name, GetT get_fn, SetT set_fn = nullptr)
33  : CommonInputImpl<GetT, SetT>(name, get_fn, set_fn)
34  {
36  "RotationImpl getter should return an sva::PTransformd");
37  }
38 
39  constexpr static size_t write_size() { return CommonInputImpl<GetT, SetT>::write_size() + 1; }
40 
42  {
44  // True for read-only
45  builder.write(std::is_same_v<SetT, std::nullptr_t>);
46  }
47 
50 };
51 
52 } // namespace details
53 
55 template<typename GetT>
56 auto Rotation(const std::string & name, GetT get_fn)
57 {
58  return details::RotationImpl(name, get_fn);
59 }
60 
62 template<typename GetT, typename SetT>
63 auto Rotation(const std::string & name, GetT get_fn, SetT set_fn)
64 {
65  return details::RotationImpl(name, get_fn, set_fn);
66 }
67 
68 } // namespace mc_rtc::gui
mc_rtc::gui::DataElement::write_size
static constexpr size_t write_size()
Definition: elements.h:106
mc_rtc::MessagePackBuilder
Definition: MessagePackBuilder.h:86
types.h
mc_rtc::gui::details::RotationImpl::write
void write(mc_rtc::MessagePackBuilder &builder)
Definition: Rotation.h:41
mc_rtc::gui::Rotation
auto Rotation(const std::string &name, GetT get_fn)
Definition: Rotation.h:56
mc_rtc::gui::details::RotationImpl::write_size
constexpr static size_t write_size()
Definition: Rotation.h:39
mc_rtc::gui::details::RotationImpl
Definition: Rotation.h:28
mc_rtc::gui::details::RotationImpl::RotationImpl
RotationImpl(const std::string &name, GetT get_fn, SetT set_fn=nullptr)
Definition: Rotation.h:32
elements.h
mc_rtc::MessagePackBuilder::write
void write()
mc_rtc::gui::details::RotationImpl::type
static constexpr auto type
Definition: Rotation.h:30
mc_rtc::gui::Elements::Rotation
@ Rotation
mc_rtc::gui::DataElement::write
void write(mc_rtc::MessagePackBuilder &builder)
Definition: elements.h:108
traits.h
mc_rtc::gui::details::CheckReturnType
Definition: traits.h:86
mc_rtc::gui::CommonInputImpl
Definition: elements.h:166
mc_rtc::gui
Definition: Observer.h:15
mc_rtc::gui::details::RotationImpl::RotationImpl
RotationImpl()
Definition: Rotation.h:49
mc_rtc::gui::Element::name
const std::string & name() const
Definition: elements.h:61