mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Fwk : Add function to get all referenced PdmObjects
This commit is contained in:
parent
86bdf5722a
commit
a4a6c30370
@ -56,6 +56,36 @@ caf::PdmObject* cafTreeNode::referencedObject() const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<caf::PdmObject*> cafTreeNode::allReferencedObjects() const
|
||||
{
|
||||
std::vector<caf::PdmObject*> objects;
|
||||
|
||||
allReferencedObjectsRecursively( this, objects );
|
||||
|
||||
return objects;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void cafTreeNode::allReferencedObjectsRecursively( const cafTreeNode* node, std::vector<caf::PdmObject*>& objects )
|
||||
{
|
||||
if ( auto obj = node->referencedObject() )
|
||||
{
|
||||
objects.push_back( obj );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
for ( auto c : node->childNodes() )
|
||||
{
|
||||
allReferencedObjectsRecursively( c, objects );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
|
@ -46,6 +46,11 @@ public:
|
||||
|
||||
virtual caf::PdmObject* referencedObject() const;
|
||||
|
||||
std::vector<caf::PdmObject*> allReferencedObjects() const;
|
||||
|
||||
private:
|
||||
static void allReferencedObjectsRecursively( const cafTreeNode* node, std::vector<caf::PdmObject*>& objects );
|
||||
|
||||
protected:
|
||||
caf::PdmChildArrayField<cafTreeNode*> m_childNodes;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user