This commit is contained in:
2026-08-12 06:16:00 +08:00
parent a672f37fae
commit 42392bbb7e
10 changed files with 246 additions and 10 deletions
+26
View File
@@ -56,6 +56,32 @@ struct structive::Type_Descriptor<Device> {
The descriptor is the structural definition of `Device`.
### 3.1 Type-level metadata
Extensions can attach compile-time attributes to the described type itself, independently
from property metadata and inheritable property defaults:
```cpp
struct Action_Category {};
struct Action {
using attribute_category = Action_Category;
static constexpr bool single_valued = false;
static constexpr bool inheritable = false;
std::string_view name;
};
return object<Device>(
type_metadata(Action{"reset"}, Action{"calibrate"}),
field<&Device::temperature>(key<"temperature">)
);
```
Use `Schema::type_attribute_count<Category>`, `Schema::has_type_attribute<Category>`,
`schema.type_attribute<Category>()` for a single-valued category, and
`schema.for_each_type_attribute<Category>(callback)` for traversal. Core stores and
validates the generic Attribute protocol but does not interpret extension-owned categories.
Type metadata is not a property default and is never copied into individual properties.
## 4. Schema guarantees
A valid schema guarantees: