55 void Name(
const std::string& name) { name_ = name; }
57 [[nodiscard]]
const std::string&
Name()
const {
return name_; }
71 void Min(
double min ) { min_ = min; }
72 [[nodiscard]]
double Min()
const {
return min_; }
74 void Max(
double max ) { max_ = max; }
75 [[nodiscard]]
double Max()
const {
return max_; }
78 void EnumList(
const std::vector<std::string>& list);
80 [[nodiscard]]
const std::vector<std::string>&
EnumList()
const;
84 void Value(
const T& value);
88 [[nodiscard]] T
Value()
const;
94 double value_float_ = 0.0;
95 std::string value_string_;
96 std::vector<std::string> enum_list_;
105 value_float_ =
static_cast<double>(value);
106 switch (value_type_) {
108 value_string_ = std::to_string(
static_cast<int64_t
>(value));
112 value_string_ = std::to_string(
static_cast<double>(value));
116 const auto index =
static_cast<size_t>(value_float_);
117 if ( index < enum_list_.size()) {
118 value_string_ = enum_list_[index];
124 value_string_ = std::to_string(value);
128 }
catch (
const std::exception&) {
130 value_string_ =
"Conversion error";
144 std::istringstream temp(value_string_);
147 }
catch (
const std::exception& ) {
153 value =
static_cast<T
>(value_float_);
Support class for handling attributes of network objects.
Definition: attribute.h:49
T Value() const
Returns the attribute value.
Definition: attribute.h:140
std::string ValueTypeAsString() const
Returns the attribute data type as string.
void ValueType(AttributeValueType type)
Sets the attribute data type.
Definition: attribute.h:65
void Min(double min)
Sets the min range.
Definition: attribute.h:71
double Max() const
Max range.
Definition: attribute.h:75
void Type(AttributeType type)
Sets the type of attribute.
Definition: attribute.h:60
const std::vector< std::string > & EnumList() const
Returns an enumerated string list.
void EnumList(const std::vector< std::string > &list)
Sets an enumerate string list.
AttributeType Type() const
Return type of attribute.
Definition: attribute.h:62
void Name(const std::string &name)
Sets the name of the attribute.
Definition: attribute.h:55
double Min() const
Min range.
Definition: attribute.h:72
Attribute(AttributeType type, const std::string &name)
Constructor for an attribute or definition.
AttributeValueType ValueType() const
Returns the attribute data type.
Definition: attribute.h:67
const std::string & Name() const
Retuns the attribute name.
Definition: attribute.h:57
void Max(double max)
Sets the max range.
Definition: attribute.h:74
Wrapper class around a CAN message.
Definition: dbcmessage.h:21
Main namespace for the DBC library.
Definition: attribute.h:13
AttributeType
Define what type of network object the attribute is valid for.
Definition: attribute.h:17
@ DbcNode
Node/Device attribute.
@ NodeSignalRelation
Node signal relation attribute.
@ NodeMessageRelation
Node message relation attribute.
@ DbcNetwork
Network attribute.
@ DbcSignal
Signal attribute.
@ EnvironmentVariable
Environment attribute.
AttributeValueType
Data type of the attribute.
Definition: attribute.h:30
@ HexValue
Hexa-decimal value.
@ EnumValue
Enumerate value.
@ IntegerValue
Integer value.
@ FloatValue
Floating point value.