diff --git a/src/proc/mobject/placement.hpp b/src/proc/mobject/placement.hpp index f494d4815..282cc89c4 100644 --- a/src/proc/mobject/placement.hpp +++ b/src/proc/mobject/placement.hpp @@ -137,7 +137,18 @@ namespace mobject { { ENSURE (*this); return _SmartPtr::operator-> (); - } + } + + /** run time diagnostics: is the pointee + * of this placement compatible to the given type? + */ + template + bool + isCompatible () const + { + return 0 != dynamic_cast (get()); + } + operator string() const ; size_t use_count() const { return _SmartPtr::use_count(); } diff --git a/tests/components/proc/mobject/placement-hierarchy-test.cpp b/tests/components/proc/mobject/placement-hierarchy-test.cpp index d6fd03cab..6ca72b590 100644 --- a/tests/components/proc/mobject/placement-hierarchy-test.cpp +++ b/tests/components/proc/mobject/placement-hierarchy-test.cpp @@ -156,6 +156,14 @@ namespace test { // { // ASSERT (lumiera_error () == error::LUMIERA_ERROR_ASSERTION); // } + + // runtime type diagnostics based on pointee RTTI + ASSERT ( pSub2.isCompatible()); + ASSERT ( pSub2.isCompatible()); + ASSERT ( pSub2.isCompatible()); + ASSERT (!pSub2.isCompatible()); + ASSERT (!pSub2.isCompatible()); + ASSERT (!pSub2.isCompatible()); } };