// SPDX-License-Identifier: MIT #ifndef DBC_ATTRIBUTES_H #define DBC_ATTRIBUTES_H #include #include #include #include #include #include /** * @brief Target scope of an attribute definition or assignment. */ enum class AttributeScope { Database, Node, Frame, Signal, Environment }; /** * @brief DBC attribute storage type. HEX values use decimal integer syntax. */ enum class AttributeType { Integer, Hex, Float, String, Enum }; /** @brief Typed attribute value; ENUM uses a zero-based integer index. */ using AttributeValue = std::variant; /** @brief Effective attribute values indexed by definition name. */ using AttributeMap = std::map; /** * @brief Attribute type, permitted range, and optional default. */ struct AttributeDefinition { AttributeScope scope = AttributeScope::Database; /**< Target scope; database when no scope marker is present. */ AttributeType type = AttributeType::String; /**< Type used to validate values. */ std::int64_t integerMinimum = 0; /**< Inclusive INT, HEX, or ENUM lower bound. */ std::int64_t integerMaximum = 0; /**< Inclusive INT, HEX, or ENUM upper bound. */ double minimum = 0.0; /**< Inclusive FLOAT lower bound. */ double maximum = 0.0; /**< Inclusive FLOAT upper bound. */ std::vector enumValues; /**< ENUM labels in index order. */ std::optional defaultValue; /**< Validated default; empty when not declared. */ }; /** * @brief Explicit assignment; defaults remain on definitions. * * Named nodes/environment variables are retained without validating declarations, * which are not parsed. */ struct AttributeAssignment { std::string name; /**< Attribute definition name. */ AttributeScope scope = AttributeScope::Database; /**< Target scope; database when no scope marker is present. */ std::uint32_t canId = 0U; /**< Normalized frame ID for frame/signal assignments. */ bool isExtended = false; /**< Frame type for frame/signal assignments. */ std::string targetName; /**< Signal, node, or environment variable name. */ AttributeValue value; /**< Validated explicit value. */ }; #endif