mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1280 Added firstAncestorOrThisOfTypeAsserted
This commit is contained in:
@@ -4,8 +4,9 @@
|
||||
|
||||
class QString;
|
||||
|
||||
#include <vector>
|
||||
#include <assert.h>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace caf
|
||||
@@ -37,6 +38,10 @@ public:
|
||||
template <typename T>
|
||||
void firstAncestorOrThisOfType(T*& ancestor) const;
|
||||
|
||||
/// Calls firstAncestorOrThisOfType, and asserts that a valid object is found
|
||||
template <typename T>
|
||||
void firstAncestorOrThisOfTypeAsserted(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>
|
||||
@@ -156,6 +161,17 @@ void PdmObjectHandle::firstAncestorOrThisOfType(T*& ancestor) const
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
void PdmObjectHandle::firstAncestorOrThisOfTypeAsserted(T*& ancestor) const
|
||||
{
|
||||
firstAncestorOrThisOfType(ancestor);
|
||||
|
||||
assert(ancestor);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user