16 : m_type(
NodeType::Root), m_name(
"dbc") {
20 : m_type(
NodeType::Frame), m_name(frame.name), m_frame(std::make_unique<
FrameInfo>(frame)) {
24 : m_type(
NodeType::Signal), m_name(signal.name), m_signal(std::make_unique<
SignalInfo>(signal)) {
29 for (
const TreeNode *ancestor =
this; ancestor; ancestor = ancestor->m_parent) {
30 if (ancestor == child.get())
31 throw std::invalid_argument(
"Cannot insert a node into its own subtree");
34 throw std::invalid_argument(
"Child is already attached");
35 m_children.push_back(std::move(child));
36 m_children.back()->m_parent =
this;
37 m_children.back()->m_row = m_children.size() - 1U;
42 return m_children.size();
46 if (index >= m_children.size())
49 return m_children[index].get();
53 if (index >= m_children.size())
56 return m_children[index].get();
72 return m_signal.get();
85 return FrameKey(m_frame->canId, m_frame->isExtended);
86 if (m_signal && m_parent && m_parent->
GetType() == NodeType::Frame)
92 const std::optional<FrameKey> frame =
GetFrameKey();
93 if (m_signal && frame)
Tree node for later use in model/view or other hierarchy consumers.
std::optional< SignalKey > GetSignalKey() const
const SignalInfo * GetSignal() const
Get signal payload if node is signal.
const TreeNode * GetChild(std::size_t index) const
Get child by index.
TreeNode()
Create root node.
const TreeNode * GetParent() const
const std::string & GetName() const
Get display name.
std::size_t GetChildCount() const
Get child count.
std::size_t GetRow() const
std::optional< FrameKey > GetFrameKey() const
void AddChild(std::unique_ptr< TreeNode > &&child)
Add child node.
NodeType GetType() const
Get node type.
const FrameInfo * GetFrame() const
Get frame payload if node is frame.
Describes one CAN frame from a DBC file.
Stable frame identifier: normalized CAN ID and frame type.
Describes one signal inside a DBC frame.
Qt-independent metadata tree nodes.
NodeType
Type of a tree node.