Lumiera  0.pre.03
»edit your freedom«
tuple-record-init.hpp File Reference

Go to the source code of this file.

Description

Specialised adapter to consume a record of GenNode entries to build a tuple.

This is a complement to lib::meta::TupleConstructor to deal with arguments passed in our "External Tree Description" form. This is relevant for structural diff and the invocation of actions driven by messages via the UI-Bus.

In those cases, a sequence of arguments will be passed within a run-time sequential container, as a sequence of GenNode entries. The latter are variant records, which means they can hold any of a small collection of basic types, like numbers, strings, time values etc. So we have to face two challenges here.

  • the sequence of types in a std::tuple is fixed at compile time, as is the sequence of constructor arguments to build a given tuple type. Thus we need a compile-time iteration over a run-time sequence container
  • the concrete type of the given initialisation value is opaque, hidden within the GenNode variant record. And especially this means that the concrete type is known only at runtime. But we need to generate the construction code at compile time. The remedy here is to use double dispatch, i.e. to build a trampoline table with all the basically possible conversion paths for one specific type within the target tuple. For example, if one component of our tuple is a long, we'll provide a conversion path for the case when the GenNode holds a short, an int, and – depending on the platform – when it holds a int64_t (please recall that long and int are the same type on 32bit platforms!). When encountering any other of the possible types within GenNode (e.g. string or TimeSpan), a type mismatch exception is raised.
See also
control::CommandDef usage example
TupleHelper_test
typelist.hpp
function.hpp
generator.hpp

Definition in file tuple-record-init.hpp.

Classes

struct  ElementExtractor< lib::diff::Rec, std::tuple< TYPES... > >::Access< i >
 
struct  GenNodeAccessor< TAR >::allow_Conversion< TY >
 
class  GenNodeAccessor< TAR >::Converter< TY, BA >
 
struct  GenNodeAccessor< TAR >::ConverterBase
 
struct  ElementExtractor< lib::diff::Rec, std::tuple< TYPES... > >
 Concrete specialisation to build a std::tuple from a sequence of GenNode elements, with run-time type compatibility check. More...
 
struct  GenNodeAccessor< TAR >
 

Typedefs

using DataCapPredicate = Variant< DataValues >::Predicate
 the visitor type our converter is based on
 

Namespaces

 lib
 Implementation namespace for support and library code.