Removed instanceOf.
I think it's time to remove MOST of the poor man's RTTI now.
This commit is contained in:
@ -95,34 +95,5 @@ void IdentifiableObject::registerName (const char *className, const std::type_in
|
|||||||
currentlyConstructedClass = klass;
|
currentlyConstructedClass = klass;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Returns, whether this class is an instance of the class, given by
|
|
||||||
* \em otherClassId, or of a sub class of this class.
|
|
||||||
*/
|
|
||||||
bool IdentifiableObject::instanceOf_impl (std::intptr_t otherClassId)
|
|
||||||
{
|
|
||||||
if (otherClassId == -1)
|
|
||||||
// Other class has not been registered yet, while it should have been,
|
|
||||||
// if this class is an instance of it or of a sub-class.
|
|
||||||
return false;
|
|
||||||
|
|
||||||
Class *otherClass = classesById.at (otherClassId);
|
|
||||||
|
|
||||||
if (otherClass == NULL) {
|
|
||||||
fprintf (stderr,
|
|
||||||
"WARNING: Something got wrong here, it seems that a "
|
|
||||||
"CLASS_ID was not initialized properly.\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Class *klass = classesById.at (classId); klass != NULL;
|
|
||||||
klass = klass->parent) {
|
|
||||||
if (klass == otherClass)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace identity
|
} // namespace identity
|
||||||
} // namespace lout
|
} // namespace lout
|
||||||
|
|||||||
@ -136,20 +136,6 @@ public:
|
|||||||
* registered.
|
* registered.
|
||||||
*/
|
*/
|
||||||
const char *getClassName() { return classesById.at( classId )->className; }
|
const char *getClassName() { return classesById.at( classId )->className; }
|
||||||
|
|
||||||
template< typename T >
|
|
||||||
[[deprecated]]
|
|
||||||
inline bool
|
|
||||||
instanceOf()
|
|
||||||
{
|
|
||||||
const bool expected= dynamic_cast< T * >( this );
|
|
||||||
const bool witness= instanceOf_impl( T::CLASS_ID );
|
|
||||||
if( witness != expected ) throw std::logic_error{ "RTTI based `instanceOf` disagrees with Dillo's lout:: impl." };
|
|
||||||
return expected;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool instanceOf_impl (std::intptr_t otherClassId);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace identity
|
} // namespace identity
|
||||||
|
|||||||
Reference in New Issue
Block a user