Skip to content

Feature request: optional visitable metadata #15

@NikolausDemmel

Description

@NikolausDemmel

I'm using visit_struct to declare structs with parameters and automatically link specific option values to GUI widgets. It works great for simple cases.

However, more often than not I would like to define additional metadata where I specify the options in the struct. For example for numeric options, I would like to specify a range with minimum and maximum acceptable value, such that a slider with the correct limits can be created in the GUI.

I'm currently working around this by using some custom types for the struct member variables, e.g.

template <class T>
struct ranged {
  using ValueType = T;
  T val {0};
  const T min {0};
  const T max {100};
};

struct Foo {

    BEGIN_VISITABLES(Foo);

    VISITABLE_INIT(bool, foo, true);
    VISITABLE_DIRECT_INIT(ranged<double>, bar, {0.5, 0, 1});
    END_VISITABLES;

};

However this is a bit awkward, as a I have to access the actual value always via the val member.

Foo foo;
foo.bar.val = 0.1;

Would it be possible to extend visit_struct to allow declaring additional (typed) meta-data for every member in such a way, that it is transparent (i.e. foo.bar refers to the actual value, not some enclosing struct containing also the metadata), and it is (optionally) accessible during visitation.

I guess for my use-cases I so far only need constant meta-data.

I'm mostly interested in the intrusive syntax, since I want to define "all in one place", but one might also consider adding metadata to existing structs with a non-intrusive syntax.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions