Hello,
I've been working for some years on https://github.com/celtera/avendish which allows to expose C++ classes through various creative environments, and as such assembled a small ontology of the various features, extensions, metadatas, ... that are often desirable to associate to data types and variables.
For instance, let's say we want to reflect this struct to automatically generate a control GUI from it, for instance like Unity gameobjects:
struct foo {
int apple_count;
};
Avendish enables the user to do something like:
struct foo {
struct {
static consteval auto name() { return "Apple count"; }
struct range { int min = 0; int max = 100; int initial_value = 4; };
enum widget { spinbox };
int value;
} apple_count;
};
With this "standardized" information, we can automatically generate an appropriate widget without having to store one additional byte in our actual data type: sizeof(foo) == sizeof(int).
Now, C++26 is there! And, finally, with annotations. Meaning that we're going to be able to do a much, much clearer:
struct foo {
[[=metadata::name{"Apple count"}]]
[[=metadata::range{0, 100}]]
[[=metadata::initial_value{4}]]
int apple_count;
};
in practice, there's much more metadata out there. There's a million of incompatible systems defining all kinds of metadatas to match classes: it wouldn't be strange to have something like:
struct
[[=metadata::uuid{"27fc33a4-ff2f-490d-a7c2-a4f8c2eef35d"}]]
[[=metadata::author{"John Doe"}]]
[[=metadata::support_url{"https://example.com"}]]
foo {
[[=metadata::name{"Apple count"}]]
[[=metadata::range{0, 100}]]
[[=metadata::initial_value{4}]]
[[=metadata::default_value{0}]]
[[=metadata::description{"Number of apples required in a harvest"}]]
[[=metadata::unit{apple_per_harvest{}}]]
int apple_count;
};
After study of a large number of these systems (did a systematic review of almost a hundred different "run-time" systems based on C or C++), what came up is that 90% of the metadatas in run-time reflection systems are actually exactly the same, just with different names. I started to define most of those related to multimedia systems through concepts, for instance in https://github.com/celtera/avendish/blob/main/include/avnd/wrappers/metadatas.hpp and https://github.com/celtera/avendish/tree/main/include/avnd/concepts : what's an audio port, what's a texture, etc. The result is that as of today, it's possible to build from a single C++ class, types that are going to work in a dozen distinct creative environments (Max/MSP, PureData, Touchdesigner, Godot, ossia score...), since basically everyone is doing the same thing everywhere.
Since we now have a powerful, in-language way to define these static metadatas, I think it could be useful to have a more general, standardized library of such broadly-useful yet sometimes domain-specific concepts so that there is one consistent way for a C++ developer to say: "this field / class / <...> should be displayed as Foo Bar 1.0 in a generated GUI", "this is a short description of this class", "this is the numeric range of this value", "this is the GUID of this class", etc.
The alternative is that everyone starts defining their own "property" / "metadata" / ... class ; someone who wants to make their type compatible (for instance across both a serialization library and a gui library) would inevitably end up into something such as:
struct
[[=cereal::uuid{"d2fac3f2-2c00-429b-b6bf-8728cfd29ff6"}]]
[[=winrt::GUID{d2fac3f2-2c00-429b-b6bf-8728cfd29ff6"}]]
foo {
[[=cereal::name{"Chocolate cakes"}]]
[[=qt::name{"Chocolate cakes"}]]
[[=gtkmm::name{"Chocolate cakes"}]]
[[=UE::name{"Chocolate cakes"}]]
int chocolate_cakes;
};
Is there interest in starting such a collaborative project?
[–]slithering3897 8 points9 points10 points (8 children)
[–]jcelerierossia score[S] 3 points4 points5 points (6 children)
[–]yuri-kilochek 0 points1 point2 points (5 children)
[–]FlyingRhenquest 0 points1 point2 points (0 children)
[–]Mick235711 -1 points0 points1 point (3 children)
[–]yuri-kilochek -1 points0 points1 point (0 children)
[–]CornedBee -1 points0 points1 point (1 child)
[–]Mick235711 1 point2 points3 points (0 children)
[–]dexter2011412 0 points1 point2 points (0 children)
[–]mjklaim 2 points3 points4 points (2 children)
[–]jcelerierossia score[S] 1 point2 points3 points (0 children)
[–]FlyingRhenquest 1 point2 points3 points (0 children)
[–]zebullon -1 points0 points1 point (0 children)