mc_rtc::schema::Operations Struct Reference

#include <mc_rtc/Schema.h>

Public Types

using FormElements = gui::details::FormElements
 

Public Member Functions

template<typename T , typename Schema , T Schema::* ptr, ValueFlag Flags = ValueFlag::All, bool HasChoices = false>
bool registerValue (details::MemberPointerWrapper< ptr >, const std::string &name, const std::string &description, const std::integral_constant< ValueFlag, Flags > &={}, const details::Choices< HasChoices > &choices={})
 

Public Attributes

size_t values_count = 0
 
std::function< void(const void *self, Configuration &out)> save = [](const void *, Configuration &) {}
 
std::function< void(const void *self, MessagePackBuilder &builder)> write
 
std::function< void(void *self, const Configuration &in)> load = [](void *, const Configuration &) {}
 
std::function< void(const void *self, FormElements &form)> buildForm = [](const void *, FormElements &) {}
 
std::function< void(const Configuration &in, Configuration &out)> formToStd
 
std::function< bool(const void *lhs, const void *rhs)> areEqual = [](const void *, const void *) { return true; }
 

Detailed Description

Helper to implement a Schema methods

Inside a schema-enabled struct, an Operations singleton should be created

When a member variable is added to the struct, it should be statically registered to the Operations singleton

When deriving a schema-enabled struct, an Operations singleton specific to this derived struct should be created and it should refer the base operations

It is advised to use the provided macros to deal with that boilerplate, namely:

  • MC_RTC_DECLARE_SCHEMA(SchemaT, BaseT) for declaring a schema-enabled struct of type SchemaT that inherits BaseT
  • MC_RTC_SCHEMA_MEMBER_*(SchemaT, ...) to declare members inside a schema-enable struct of type SchemaT

Member Typedef Documentation

◆ FormElements

Member Function Documentation

◆ registerValue()

template<typename T , typename Schema , T Schema::* ptr, ValueFlag Flags = ValueFlag::All, bool HasChoices = false>
bool mc_rtc::schema::Operations::registerValue ( details::MemberPointerWrapper< ptr >  ,
const std::string &  name,
const std::string &  description,
const std::integral_constant< ValueFlag, Flags > &  = {},
const details::Choices< HasChoices > &  choices = {} 
)
inline

FIXME Add a saveSchema function FIXME Add logging operation? Register a value

Template Parameters
SchemaSchema this value belongs to
ptrMember pointer in the Schema object
FlagsControl some features of the value in the schema
HasChoicesIf true, we expect choices to be provided for the value instead of an open form
Parameters
nameName of the value
descriptionDescription for the value
choicesPossible choices when
Template Parameters
HasChoicesis true

Member Data Documentation

◆ areEqual

std::function<bool(const void * lhs, const void * rhs)> mc_rtc::schema::Operations::areEqual = [](const void *, const void *) { return true; }

Compare two objects

◆ buildForm

std::function<void(const void * self, FormElements & form)> mc_rtc::schema::Operations::buildForm = [](const void *, FormElements &) {}

Build a Form to load the object

◆ formToStd

std::function<void(const Configuration & in, Configuration & out)> mc_rtc::schema::Operations::formToStd
Initial value:
= [](const Configuration &,

Convert a form configuration to the configuration expected by load

◆ load

std::function<void(void * self, const Configuration & in)> mc_rtc::schema::Operations::load = [](void *, const Configuration &) {}

Load from a configuration object

◆ save

std::function<void(const void * self, Configuration & out)> mc_rtc::schema::Operations::save = [](const void *, Configuration &) {}

Save to a configuration object

◆ values_count

size_t mc_rtc::schema::Operations::values_count = 0

Name of members in the schema

◆ write

std::function<void(const void * self, MessagePackBuilder & builder)> mc_rtc::schema::Operations::write
Initial value:
= [](const void *, MessagePackBuilder &) {
}

Write to a MessagePackBuilder


The documentation for this struct was generated from the following file:
mc_rtc::Configuration
struct MC_RTC_UTILS_DLLAPI Configuration
Definition: Configuration.h:46