WIP: add run-time type check API to Placement

This commit is contained in:
Fischlurch 2009-06-06 04:02:08 +02:00
parent 608c532df7
commit 638022c07f
2 changed files with 20 additions and 1 deletions

View file

@ -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<class Y>
bool
isCompatible () const
{
return 0 != dynamic_cast<const Y*> (get());
}
operator string() const ;
size_t use_count() const { return _SmartPtr::use_count(); }

View file

@ -156,6 +156,14 @@ namespace test {
// {
// ASSERT (lumiera_error () == error::LUMIERA_ERROR_ASSERTION);
// }
// runtime type diagnostics based on pointee RTTI
ASSERT ( pSub2.isCompatible<MObject>());
ASSERT ( pSub2.isCompatible<DummyMO>());
ASSERT ( pSub2.isCompatible<TestSubMO2>());
ASSERT (!pSub2.isCompatible<TestSubMO21>());
ASSERT (!pSub2.isCompatible<TestSubMO1>());
ASSERT (!pSub2.isCompatible<Clip>());
}
};