mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-21 22:13:25 -06:00
AppFwk : Added descendantsIncludingThisOfType
This commit is contained in:
parent
33abbed1fd
commit
59afd14339
@ -35,6 +35,11 @@ public:
|
||||
template <typename T>
|
||||
void firstAnchestorOrThisOfType(T*& ancestor) const;
|
||||
|
||||
/// Traverses all children recursively to find objects of the requested type. This object is also
|
||||
/// included if it is of the requested type.
|
||||
template <typename T>
|
||||
void descendantsIncludingThisOfType(std::vector<T*>& descendants) const;
|
||||
|
||||
// PtrReferences
|
||||
/// The PdmPtrField's containing pointers to this PdmObjecthandle
|
||||
/// Use ownerObject() on the fieldHandle to get the PdmObjectHandle
|
||||
@ -149,5 +154,29 @@ void PdmObjectHandle::firstAnchestorOrThisOfType(T*& ancestor) const
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
void PdmObjectHandle::descendantsIncludingThisOfType(std::vector<T*>& descendants) const
|
||||
{
|
||||
const T* objectOfType = dynamic_cast<const T*>(this);
|
||||
if (objectOfType)
|
||||
{
|
||||
descendants.push_back(const_cast<T*>(objectOfType));
|
||||
}
|
||||
|
||||
for (auto f : m_fields)
|
||||
{
|
||||
std::vector<PdmObjectHandle*> childObjects;
|
||||
f->childObjects(&childObjects);
|
||||
|
||||
for (auto childObject : childObjects)
|
||||
{
|
||||
childObject->descendantsIncludingThisOfType(descendants);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace caf
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user