Skip to main content

chronon::tree::ResourceNode

Tree node that owns a typed resource with lazy instantiation. More...

#include <TreeNode.hpp>

Inherits from chronon::tree::TreeNode

Public Types

Name
using typename ResourceT::ParameterSetParameterSetT

Public Functions

Name
ResourceT *resource()
Get or lazily create the resource.
const ResourceT *resource() const
const ParameterSetT &params() const
ParameterSetT &params()
Mutable parameter access.
boolisInstantiated() const
ResourceNode(const std::string & name, const ParameterSetT & params, TreeNode * parent =nullptr)

Additional inherited members

Public Types inherited from chronon::tree::TreeNode

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

Public Functions inherited from chronon::tree::TreeNode

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 inherited from chronon::tree::TreeNode

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

Detailed Description

template <typename ResourceT >
class chronon::tree::ResourceNode;

Tree node that owns a typed resource with lazy instantiation.

Template Parameters:

ROB::ParameterSet params;
params.retire_width = 8;
auto node = std::make_unique<ResourceNode<ROB>>("rob", params);
ROB* rob = node->resource(); // Lazy instantiation

Public Types Documentation

using ParameterSetT

using chronon::tree::ResourceNode< ResourceT >::ParameterSetT = typename ResourceT::ParameterSet;

Public Functions Documentation

function resource

inline ResourceT * resource()

Get or lazily create the resource.

Exceptions:

  • std::runtime_error if phase is not BINDING or FINALIZED.

function resource

inline const ResourceT * resource() const

Return: Resource pointer, or nullptr if not yet instantiated.

function params

inline const ParameterSetT & params() const

function params

inline ParameterSetT & params()

Mutable parameter access.

Exceptions:

  • std::runtime_error if phase is not BUILDING or CONFIGURING.

function isInstantiated

inline bool isInstantiated() const

function ResourceNode

inline ResourceNode(
const std::string & name,
const ParameterSetT & params,
TreeNode * parent =nullptr
)

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