Skip to content

Commit

Permalink
Convert RootId to NodeId explicitly with namespace (#583)
Browse files Browse the repository at this point in the history
Co-authored-by: Corinna John <corinna.john@adesso.de>
  • Loading branch information
c0c0bird and Corinna John authored Jan 15, 2024
1 parent cf2c5f1 commit 125ed2b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
18 changes: 18 additions & 0 deletions Workshop/Common/NodeHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,24 @@ public string RootId
}
}

/// <summary>
/// A unique identifier for the root of a complex object tree.
/// Like <see cref="RootId"/>, but combined with the namespace.
/// </summary>
public NodeId RootNodeId
{
get
{
if (ParsedNodeId != null)
{
// the RootId does not contain a namespace, so it has to be re-constructed to be used as a NodeId
return new NodeId(ParsedNodeId.RootId, ParsedNodeId.NamespaceIndex);
}

return null;
}
}

/// <summary>
/// A path to a component within the tree identified by the root id.
/// </summary>
Expand Down
8 changes: 4 additions & 4 deletions Workshop/Common/QuickstartNodeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4060,7 +4060,7 @@ protected NodeState LookupNodeInComponentCache(ISystemContext context, NodeHandl

if (!String.IsNullOrEmpty(handle.ComponentPath))
{
if (m_componentCache.TryGetValue(handle.RootId, out entry))
if (m_componentCache.TryGetValue(handle.RootNodeId, out entry))
{
return entry.Entry.FindChildBySymbolicName(context, handle.ComponentPath);
}
Expand Down Expand Up @@ -4095,7 +4095,7 @@ protected void RemoveNodeFromComponentCache(ISystemContext context, NodeHandle h

if (!String.IsNullOrEmpty(handle.ComponentPath))
{
nodeId = handle.RootId;
nodeId = handle.RootNodeId;
}

CacheEntry entry = null;
Expand Down Expand Up @@ -4135,7 +4135,7 @@ protected NodeState AddNodeToComponentCache(ISystemContext context, NodeHandle h
{
CacheEntry entry = null;

if (m_componentCache.TryGetValue(handle.RootId, out entry))
if (m_componentCache.TryGetValue(handle.RootNodeId, out entry))
{
entry.RefCount++;

Expand All @@ -4154,7 +4154,7 @@ protected NodeState AddNodeToComponentCache(ISystemContext context, NodeHandle h
entry = new CacheEntry();
entry.RefCount = 1;
entry.Entry = root;
m_componentCache.Add(handle.RootId, entry);
m_componentCache.Add(handle.RootNodeId, entry);
}
}

Expand Down

0 comments on commit 125ed2b

Please sign in to comment.