DBC Framework
DBC parsing and CAN signal decoding framework
Loading...
Searching...
No Matches
tree_node.cpp
Go to the documentation of this file.
1
12#include "tree_node.h"
13
15 : m_type(NodeType::Root), m_name("dbc"), m_children(), m_frame(), m_signal() {
16}
17
19 : m_type(NodeType::Frame), m_name(frame.name), m_children(), m_frame(new FrameInfo(frame)), m_signal() {
20}
21
23 : m_type(NodeType::Signal), m_name(signal.name), m_children(), m_frame(), m_signal(new SignalInfo(signal)) {
24}
25
26void TreeNode::AddChild(std::unique_ptr<TreeNode> child) {
27 if (child)
28 m_children.push_back(std::move(child));
29}
30
31std::size_t TreeNode::GetChildCount() const {
32 return m_children.size();
33}
34
35const TreeNode *TreeNode::GetChild(std::size_t index) const {
36 if (index >= m_children.size())
37 return nullptr;
38
39 return m_children[index].get();
40}
41
42TreeNode *TreeNode::GetChild(std::size_t index) {
43 if (index >= m_children.size())
44 return nullptr;
45
46 return m_children[index].get();
47}
48
50 return m_type;
51}
52
53const std::string &TreeNode::GetName() const {
54 return m_name;
55}
56
58 return m_frame.get();
59}
60
62 return m_signal.get();
63}
Tree node for later use in model/view or other hierarchy consumers.
Definition tree_node.h:35
const SignalInfo * GetSignal() const
Get signal payload if node is signal.
Definition tree_node.cpp:61
const TreeNode * GetChild(std::size_t index) const
Get child by index.
Definition tree_node.cpp:35
void AddChild(std::unique_ptr< TreeNode > child)
Add child node.
Definition tree_node.cpp:26
TreeNode()
Create root node.
Definition tree_node.cpp:14
const std::string & GetName() const
Get display name.
Definition tree_node.cpp:53
std::size_t GetChildCount() const
Get child count.
Definition tree_node.cpp:31
NodeType GetType() const
Get node type.
Definition tree_node.cpp:49
const FrameInfo * GetFrame() const
Get frame payload if node is frame.
Definition tree_node.cpp:57
Describes one CAN frame from a DBC file.
Definition frame_info.h:24
Describes one signal inside a DBC frame.
Definition signal_info.h:22
Created: 2026-03-13 Author: Deeaitch (Dim. Himro)
NodeType
Type of a tree node.
Definition tree_node.h:26