Skip to main content

chronon::tree::TreeNode

Hierarchical tree node with path-based addressing and parameter inheritance. More...

#include <TreeNode.hpp>

Inherited by chronon::tree::ResourceNode< ResourceT >

Public Types

Name
enum classPhase { FINALIZED, CONFIGURING, BUILDING, BINDING}
Lifecycle phases for tree construction.

Public Functions

Name
virtual~TreeNode() =default
voidtransitionPhaseRecursive(Phase new_phase)
Recursively transition this node and all descendants.
voidtransitionPhase(Phase new_phase)
Transition to a new lifecycle phase.
voidsetScheduler(chronon::Scheduler * scheduler)
Set scheduler reference (typically on root during SimulationBuilderPhase 2).
voidsetResource(std::shared_ptr< void > resource)
Store a type-erased shared resource pointer.
TreeNode *root()
const TreeNode *root() const
std::stringphaseToString(Phase p)
Phasephase() const
std::stringpath() const
Full dotted path from root (e.g. "cpu.core0.rob").
TreeNode *parent() const
TreeNode &operator=(const TreeNode & ) =delete
TreeNode &operator=(TreeNode && ) =default
const std::string &name() const
boolisRoot() const
boolhasResource() const
chronon::Scheduler *getScheduler() const
Get scheduler, traversing up to root.
template <typename T >
T *
getResource() const
Get resource cast to T.
TreeNode *getChildByRelativePath(const std::string & path)
Look up a descendant by relative dotted path (e.g. "core0.rob").
const TreeNode *getChildByRelativePath(const std::string & path) const
TreeNode *getChild(const std::string & path)
Look up a descendant by relative dotted path (e.g. "core0.rob").
const TreeNode *getChild(const std::string & path) const
TreeNode *findByPath(const std::string & absolute_path)
Find a node by absolute path from root (e.g. "cpu.core0.rob").
const TreeNode *findByPath(const std::string & absolute_path) const
TreeNode *findByAbsolutePath(const std::string & absolute_path)
Find a node by absolute path from root (e.g. "cpu.core0.rob").
const TreeNode *findByAbsolutePath(const std::string & absolute_path) const
const std::unordered_map< std::string, std::unique_ptr< TreeNode > > &children() const
voidaddChild(const std::string & name, std::unique_ptr< TreeNode > child)
Add a child node, taking ownership.
TreeNode(const std::string & name, TreeNode * parent =nullptr)
TreeNode(const TreeNode & ) =delete
TreeNode(TreeNode && ) =default

Protected Attributes

Name
chronon::Scheduler *scheduler_
Not owned; typically set on root only.
std::shared_ptr< void >resource_
Phasephase_
TreeNode *parent_
std::stringname_
std::unordered_map< std::string, std::unique_ptr< TreeNode > >children_

Detailed Description

class chronon::tree::TreeNode;

Hierarchical tree node with path-based addressing and parameter inheritance.

Foundation for the resource hierarchy system.

auto root = std::make_unique<TreeNode>("cpu");
auto core0 = std::make_unique<TreeNode>("core0", root.get());
root->addChild("core0", std::move(core0));
std::string path = root->getChildByRelativePath("core0")->path(); // "cpu.core0"

Public Types Documentation

enum Phase

EnumeratorValueDescription
FINALIZEDReady for simulation (immutable)
CONFIGURINGParameter application (setParam allowed)
BUILDINGTree construction (addChild allowed)
BINDINGPort and connection setup.

Lifecycle phases for tree construction.

Progression: BUILDING → CONFIGURING → BINDING → FINALIZED.

Public Functions Documentation

function ~TreeNode

virtual ~TreeNode() =default

function transitionPhaseRecursive

void transitionPhaseRecursive(
Phase new_phase
)

Recursively transition this node and all descendants.

function transitionPhase

void transitionPhase(
Phase new_phase
)

Transition to a new lifecycle phase.

Exceptions:

  • std::runtime_error if the transition is invalid.

function setScheduler

inline void setScheduler(
chronon::Scheduler * scheduler
)

Set scheduler reference (typically on root during SimulationBuilderPhase 2).

function setResource

inline void setResource(
std::shared_ptr< void > resource
)

Store a type-erased shared resource pointer.

function root

TreeNode * root()

function root

const TreeNode * root() const

function phaseToString

static std::string phaseToString(
Phase p
)

function phase

inline Phase phase() const

function path

std::string path() const

Full dotted path from root (e.g. "cpu.core0.rob").

function parent

inline TreeNode * parent() const

function operator=

TreeNode & operator=(
const TreeNode &
) =delete

function operator=

TreeNode & operator=(
TreeNode &&
) =default

function name

inline const std::string & name() const

function isRoot

inline bool isRoot() const

function hasResource

inline bool hasResource() const

function getScheduler

chronon::Scheduler * getScheduler() const

Get scheduler, traversing up to root.

function getResource

template <typename T >
inline T * getResource() const

Get resource cast to T.

No type checking is performed — caller must ensure the type matches.

function getChildByRelativePath

TreeNode * getChildByRelativePath(
const std::string & path
)

Look up a descendant by relative dotted path (e.g. "core0.rob").

Preferred semantic name for getChild().

function getChildByRelativePath

const TreeNode * getChildByRelativePath(
const std::string & path
) const

function getChild

TreeNode * getChild(
const std::string & path
)

Look up a descendant by relative dotted path (e.g. "core0.rob").

Return: Pointer to the node, or nullptr if not found.

function getChild

const TreeNode * getChild(
const std::string & path
) const

function findByPath

TreeNode * findByPath(
const std::string & absolute_path
)

Find a node by absolute path from root (e.g. "cpu.core0.rob").

Return: Pointer to node, or nullptr if not found.

function findByPath

const TreeNode * findByPath(
const std::string & absolute_path
) const

function findByAbsolutePath

TreeNode * findByAbsolutePath(
const std::string & absolute_path
)

Find a node by absolute path from root (e.g. "cpu.core0.rob").

Preferred semantic name for findByPath().

function findByAbsolutePath

const TreeNode * findByAbsolutePath(
const std::string & absolute_path
) const

function children

inline const std::unordered_map< std::string, std::unique_ptr< TreeNode > > & children() const

function addChild

void addChild(
const std::string & name,
std::unique_ptr< TreeNode > child
)

Add a child node, taking ownership.

Exceptions:

  • std::runtime_error if phase is not BUILDING or a sibling has the same name.

function TreeNode

explicit TreeNode(
const std::string & name,
TreeNode * parent =nullptr
)

Parameters:

  • name Node name (must be unique among siblings).
  • parent Parent node (nullptr for root).

function TreeNode

TreeNode(
const TreeNode &
) =delete

function TreeNode

TreeNode(
TreeNode &&
) =default

Protected Attributes Documentation

variable scheduler_

chronon::Scheduler * scheduler_ = nullptr;

Not owned; typically set on root only.

variable resource_

std::shared_ptr< void > resource_;

variable phase_

Phase phase_ = Phase::BUILDING;

variable parent_

TreeNode * parent_;

variable name_

std::string name_;

variable children_

std::unordered_map< std::string, std::unique_ptr< TreeNode > > children_;

Updated on 2026-05-26 at 05:42:32 +0000