54 lines
1.2 KiB
C++
54 lines
1.2 KiB
C++
// SPDX-License-Identifier: MIT
|
|
#ifndef DBC_ATTRIBUTES_H
|
|
#define DBC_ATTRIBUTES_H
|
|
|
|
#include <cstdint>
|
|
#include <map>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <variant>
|
|
#include <vector>
|
|
|
|
enum class AttributeScope {
|
|
Database,
|
|
Node,
|
|
Frame,
|
|
Signal,
|
|
Environment
|
|
};
|
|
|
|
enum class AttributeType {
|
|
Integer,
|
|
Hex,
|
|
Float,
|
|
String,
|
|
Enum
|
|
};
|
|
|
|
using AttributeValue = std::variant<std::int64_t, double, std::string>;
|
|
using AttributeMap = std::map<std::string, AttributeValue>;
|
|
|
|
struct AttributeDefinition {
|
|
AttributeScope scope = AttributeScope::Database;
|
|
AttributeType type = AttributeType::String;
|
|
std::int64_t integerMinimum = 0;
|
|
std::int64_t integerMaximum = 0;
|
|
double minimum = 0.0;
|
|
double maximum = 0.0;
|
|
std::vector<std::string> enumValues;
|
|
std::optional<AttributeValue> defaultValue;
|
|
};
|
|
|
|
/** Explicit assignment; defaults remain on definitions. Named nodes/environment
|
|
* variables are retained without validating declarations, which are not parsed. */
|
|
struct AttributeAssignment {
|
|
std::string name;
|
|
AttributeScope scope = AttributeScope::Database;
|
|
std::uint32_t canId = 0U;
|
|
bool isExtended = false;
|
|
std::string targetName;
|
|
AttributeValue value;
|
|
};
|
|
|
|
#endif
|