DBC Framework
DBC parsing and CAN signal decoding framework
Loading...
Searching...
No Matches
definition_key.h
1
// SPDX-License-Identifier: MIT
2
// Copyright (c) 2026 Dim Himro
3
4
#ifndef DEFINITION_KEY_H
5
#define DEFINITION_KEY_H
6
7
#include <cstdint>
8
#include <functional>
9
#include <string>
10
#include <utility>
11
15
struct
FrameKey
{
16
std::uint32_t canId = 0U;
17
bool
isExtended =
false
;
18
19
FrameKey
() =
default
;
20
21
FrameKey
(std::uint32_t
id
,
bool
extended)
22
: canId(
id
), isExtended(extended) {
23
}
24
25
bool
operator==(
const
FrameKey
&other)
const
{
26
return
(canId == other.canId) && (isExtended == other.isExtended);
27
}
28
};
29
33
struct
FrameKeyHasher
{
34
std::size_t operator()(
const
FrameKey
&key)
const
{
35
const
std::size_t a =
static_cast<
std::size_t
>
(key.canId);
36
const
std::size_t b = key.isExtended ? 1U : 0U;
37
return
(a * 1315423911U) ^ b;
38
}
39
};
40
42
struct
SignalKey
{
43
FrameKey
frame;
44
std::string name;
45
46
SignalKey
() =
default
;
47
SignalKey
(
FrameKey
frameKey, std::string signalName)
48
: frame(frameKey), name(std::move(signalName)) {
49
}
50
51
bool
operator==(
const
SignalKey
&other)
const
{
52
return
frame == other.frame && name == other.name;
53
}
54
};
55
56
struct
SignalKeyHasher
{
57
std::size_t operator()(
const
SignalKey
&key)
const
{
58
return
FrameKeyHasher
()(key.frame) ^ (std::hash<std::string>()(key.name) << 1U);
59
}
60
};
61
62
#endif
/* DEFINITION_KEY_H */
FrameKeyHasher
Hasher for frame key.
Definition
definition_key.h:33
FrameKey
Stable frame identifier: normalized CAN ID and frame type.
Definition
definition_key.h:15
SignalKeyHasher
Definition
definition_key.h:56
SignalKey
Definition
definition_key.h:42
core
definition_key.h
Generated by
1.9.8