#1280 Added firstAncestorOrThisOfTypeAsserted

This commit is contained in:
Magne Sjaastad
2017-03-02 13:39:15 +01:00
parent f15d698342
commit 3089abc83d

View File

@@ -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);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------