DMI_ATTRIBUTE_VARIANT
Synopsis
#include <opendmi/attribute.h>
DMI_ATTRIBUTE_VARIANT(structure, selector, { ... })
DMI_VARIANT(value, structure, member, TYPE, { ... })
DMI_VARIANT_DEFAULT(structure, member, TYPE, { ... })
DMI_VARIANTS({ variant, ..., {} })
Description
A variant attribute describes a value differently depending on the member
selector, e.g. a field which means one thing for one kind of device and
another for another, or which the structure holds only when a flag says so.
The attribute itself carries the code, the name and the level of the value,
and each of its variants, the description of the value for one value of the
selector, see DMI_ATTRIBUTE.
DMI_ATTRIBUTE_VARIANT-
Variant attribute, whose
.variantslists the variants. DMI_VARIANT-
Variant used when the selector equals
value. DMI_VARIANT_DEFAULT-
Variant used when no other one matches the selector.
DMI_VARIANTS-
List of the variants, terminated by an empty variant,
{}, which the list itself ends with.
The variant matching the selector describes the value, see
dmi_attribute_resolve, and the code, name and level of the variant itself
are not used. If no variant matches and there is no default one, the value
does not exist, and is left out.
Parameters
structure-
Type of the structure holding the selector and the value.
selector-
Member the variant is chosen by, e.g. a type, or a
boolmember telling whether the structure holds the value, seeDMI_FIELD_GROUP. value-
Value of the selector the variant is used for.
member,TYPE,{ … }-
Member, type and parameters of the attribute the variant describes the value as, see
DMI_ATTRIBUTE.
Example
Disable reason of a trusted module, which is there only when the module is disabled:
DMI_ATTRIBUTE_VARIANT(dmi_hpe_trusted_module_t, presence, {
.code = "disable-reason",
.name = "Disable reason",
.variants = DMI_VARIANTS({
DMI_VARIANT(DMI_HPE_TM_PRESENCE_DISABLED, dmi_hpe_trusted_module_t, disable_reason, ENUM, {
.values = &dmi_hpe_tm_disable_reason_names
}),
{}
})
}),