Schema.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 
22 template<typename Callback>
23 struct SchemaImpl : public CallbackElement<Element, Callback>
24 {
25  static constexpr auto type = Elements::Schema;
26 
27  SchemaImpl(const std::string & name, const std::string & schema, Callback cb)
28  : CallbackElement<Element, Callback>(name, cb), schema_(schema)
29  {
30  }
31 
32  static constexpr size_t write_size() { return CallbackElement<Element, Callback>::write_size() + 1; }
33 
35  {
37  builder.write(schema_);
38  }
39 
40 private:
41  std::string schema_;
42 };
43 
44 } // namespace details
45 
47 template<typename Callback>
48 auto Schema(const std::string & name, const std::string & schema, Callback cb)
49 {
50  return details::SchemaImpl(name, schema, cb);
51 }
52 
53 } // namespace mc_rtc::gui
auto write(T &value)
Definition: traits.h:224
Definition: Observer.h:16
auto Schema(const std::string &name, const std::string &schema, Callback cb)
Definition: Schema.h:48
Definition: MessagePackBuilder.h:87
Definition: elements.h:127
Definition: elements.h:59
const std::string & name() const
Definition: elements.h:61
Definition: Schema.h:24
SchemaImpl(const std::string &name, const std::string &schema, Callback cb)
Definition: Schema.h:27
void write(mc_rtc::MessagePackBuilder &builder)
Definition: Schema.h:34
static constexpr auto type
Definition: Schema.h:25
static constexpr size_t write_size()
Definition: Schema.h:32