Enumerations#
An enumeration definition is a kind of attribute definition whose instances are limited to specific set of enumerated values.
An enumeration usage is an attribute usage that is required to have a single definition that is an enumeration definition.
Mapping to C++#
Enumerations are mapped to an C++ enum class with a type as defined by the parameter ‘EnumBaseTypeForEvents’.
Example#
SysML v2 source code:
// definition of events accepted by a state machine
enum def StatefulPartEvent {
//@StatefulPart
ev1;
ev2;
ev3;
}C++ source code:
enum class StatefulPartEvent : std::int16_t {
None = 0, // sentinel for "no value"
ev1,
ev2,
ev3
};