The Sparta Modeling Framework
Loading...
Searching...
No Matches
TreeUtils.hpp
Go to the documentation of this file.
1// <TreeUtils.h> -*- C++ -*-
2
3
10#pragma once
11
12#include <string>
13#include <cinttypes>
14#include <vector>
15
17
18namespace sparta::utils
19{
35 uint64_t recursiveTreeSearch(sparta::TreeNode * starting_node,
36 const std::string & name,
37 std::vector<sparta::TreeNode*> & found_nodes)
38 {
39 // XXXX check for dots
40 if(starting_node->getName() == name) {
41 found_nodes.emplace_back(starting_node);
42 }
43 else {
44 for(auto child : starting_node->getChildren()) {
45 recursiveTreeSearch(child, name, found_nodes);
46 }
47 }
48 return found_nodes.size();
49 }
50}
Basic Node framework in sparta device tree composite pattern.
uint64_t recursiveTreeSearch(sparta::TreeNode *starting_node, const std::string &name, std::vector< sparta::TreeNode * > &found_nodes)
Search a TreeNode for a given named node.
Definition TreeUtils.hpp:35
Node in a composite tree representing a sparta Tree item.
Definition TreeNode.hpp:205
const ChildrenVector getChildren() const
Gets a vector of all children of this node in any group in the order in which they were added to this...
const std::string & getName() const override
Gets the name of this node.