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::ParameterSet | ParameterSetT |
Public Functions
| Name | |
|---|---|
| ResourceT * | resource() Get or lazily create the resource. |
| const ResourceT * | resource() const |
| const ParameterSetT & | params() const |
| ParameterSetT & | params() Mutable parameter access. |
| bool | isInstantiated() const |
| ResourceNode(const std::string & name, const ParameterSetT & params, TreeNode * parent =nullptr) |
Additional inherited members
Public Types inherited from chronon::tree::TreeNode
| Name | |
|---|---|
| enum class | Phase { FINALIZED, CONFIGURING, BUILDING, BINDING} Lifecycle phases for tree construction. |
Public Functions inherited from chronon::tree::TreeNode
| Name | |
|---|---|
| virtual | ~TreeNode() =default |
| void | transitionPhaseRecursive(Phase new_phase) Recursively transition this node and all descendants. |
| void | transitionPhase(Phase new_phase) Transition to a new lifecycle phase. |
| void | setScheduler(chronon::Scheduler * scheduler) Set scheduler reference (typically on root during SimulationBuilderPhase 2). |
| void | setResource(std::shared_ptr< void > resource) Store a type-erased shared resource pointer. |
| TreeNode * | root() |
| const TreeNode * | root() const |
| std::string | phaseToString(Phase p) |
| Phase | phase() const |
| std::string | path() 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 |
| bool | isRoot() const |
| bool | hasResource() 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 |
| void | addChild(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. |
| Phase | phase_ |
| TreeNode * | parent_ |
| std::string | name_ |
| 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:
- ResourceT Resource type with a nested ParameterSet.
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