@@ -44,7 +44,8 @@ class Document::Cache
4444 // Clear the existing cache.
4545 portElementMap.clear ();
4646 nodeDefMap.clear ();
47- implementationMap.clear ();
47+ implementationDirectMap.clear ();
48+ implementationIndirectMap.clear ();
4849
4950 // Traverse the document to build a new cache.
5051 for (ElementPtr elem : doc.lock ()->traverseTree ())
@@ -88,12 +89,26 @@ class Document::Cache
8889 {
8990 if (interface->isA <NodeGraph>())
9091 {
91- implementationMap[interface->getQualifiedName (nodeDefString)].push_back (interface);
92+ implementationDirectMap[interface->getQualifiedName (nodeDefString)].push_back (interface);
93+ implementationIndirectMap[interface->getQualifiedName (nodeDefString)].push_back (interface);
9294 }
9395 ImplementationPtr impl = interface->asA <Implementation>();
9496 if (impl)
9597 {
96- implementationMap[interface->getQualifiedName (nodeDefString)].push_back (interface);
98+ implementationDirectMap[interface->getQualifiedName (nodeDefString)].push_back (interface);
99+
100+ // Check for implementation which specifies a nodegraph as the implementation
101+ const string& nodeGraphString = impl->getNodeGraph ();
102+ if (!nodeGraphString.empty ())
103+ {
104+ NodeGraphPtr nodeGraph = impl->getDocument ()->getNodeGraph (nodeGraphString);
105+ if (nodeGraph)
106+ implementationIndirectMap[interface->getQualifiedName (nodeDefString)].push_back (nodeGraph);
107+ }
108+ else
109+ {
110+ implementationIndirectMap[interface->getQualifiedName (nodeDefString)].push_back (interface);
111+ }
97112 }
98113 }
99114 }
@@ -109,7 +124,8 @@ class Document::Cache
109124 bool valid;
110125 std::unordered_map<string, std::vector<PortElementPtr>> portElementMap;
111126 std::unordered_map<string, std::vector<NodeDefPtr>> nodeDefMap;
112- std::unordered_map<string, std::vector<InterfaceElementPtr>> implementationMap;
127+ std::unordered_map<string, std::vector<InterfaceElementPtr>> implementationDirectMap;
128+ std::unordered_map<string, std::vector<InterfaceElementPtr>> implementationIndirectMap;
113129};
114130
115131//
@@ -374,9 +390,28 @@ vector<InterfaceElementPtr> Document::getMatchingImplementations(const string& n
374390 _cache->refresh ();
375391
376392 // Return all implementations matching the given nodedef string.
377- if (_cache->implementationMap .count (nodeDef))
393+ if (_cache->implementationIndirectMap .count (nodeDef))
378394 {
379- matchingImplementations.insert (matchingImplementations.end (), _cache->implementationMap .at (nodeDef).begin (), _cache->implementationMap .at (nodeDef).end ());
395+ matchingImplementations.insert (matchingImplementations.end (), _cache->implementationIndirectMap .at (nodeDef).begin (), _cache->implementationIndirectMap .at (nodeDef).end ());
396+ }
397+
398+ return matchingImplementations;
399+ }
400+
401+ vector<InterfaceElementPtr> Document::getMatchingUnmappedImplementations (const string& nodeDef) const
402+ {
403+ // Recurse to data library if present.
404+ vector<InterfaceElementPtr> matchingImplementations = hasDataLibrary () ?
405+ getDataLibrary ()->getMatchingUnmappedImplementations (nodeDef) :
406+ vector<InterfaceElementPtr>();
407+
408+ // Refresh the cache.
409+ _cache->refresh ();
410+
411+ // Return all implementations matching the given nodedef string.
412+ if (_cache->implementationDirectMap .count (nodeDef))
413+ {
414+ matchingImplementations.insert (matchingImplementations.end (), _cache->implementationDirectMap .at (nodeDef).begin (), _cache->implementationDirectMap .at (nodeDef).end ());
380415 }
381416
382417 return matchingImplementations;
0 commit comments