25 lines
742 B
C++
25 lines
742 B
C++
#include <structive/property/extensions/presentation.hpp>
|
|
#include <iostream>
|
|
using namespace structive;
|
|
struct Device : Property_Object<Device> {
|
|
double temperature{25.0};
|
|
};
|
|
template <>
|
|
struct structive::Type_Descriptor<Device> {
|
|
static auto get() {
|
|
return object<Device>(
|
|
field < &Device::temperature > (
|
|
key < "temperature" >,
|
|
unit < "C" >,
|
|
presentation::label < "Temperature" >,
|
|
presentation::description < "Current device temperature" >
|
|
)
|
|
);
|
|
}
|
|
};
|
|
int main() {
|
|
Device device;
|
|
auto info = presentation::describe < &Device::temperature > (device.schema());
|
|
std::cout << info.key << '=' << info.label << '\n';
|
|
}
|