ClassIDs are now actually typeinfo name pointers.
I'll see, next, about the `instanceOf` thing, and going with more normal RTTI routes.
This commit is contained in:
@ -31,11 +31,11 @@ namespace identity {
|
||||
using namespace object;
|
||||
using namespace container::typed;
|
||||
|
||||
IdentifiableObject::Class::Class (IdentifiableObject::Class *parent, int id,
|
||||
IdentifiableObject::Class::Class (IdentifiableObject::Class *parent, const std::type_index id,
|
||||
const char *className)
|
||||
: id( (std::intptr_t) id.name() )
|
||||
{
|
||||
this->parent = parent;
|
||||
this->id = id;
|
||||
this->className = className;
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ void IdentifiableObject::Class::intoStringBuffer(misc::StringBuffer *sb)
|
||||
|
||||
std::map< std::string, std::unique_ptr< IdentifiableObject::Class > > IdentifiableObject::classesByName;
|
||||
|
||||
std::vector< IdentifiableObject::Class * > IdentifiableObject::classesById;
|
||||
std::map< std::intptr_t, IdentifiableObject::Class * > IdentifiableObject::classesById;
|
||||
|
||||
IdentifiableObject::Class *IdentifiableObject::currentlyConstructedClass;
|
||||
|
||||
@ -79,13 +79,13 @@ void IdentifiableObject::intoStringBuffer(misc::StringBuffer *sb)
|
||||
* \brief This method must be called in the constructor for the sub class.
|
||||
* See class comment for details.
|
||||
*/
|
||||
void IdentifiableObject::registerName (const char *className, int *classId)
|
||||
void IdentifiableObject::registerName (const char *className, const std::type_index index, std::intptr_t *classId)
|
||||
{
|
||||
if (not classesByName.contains( className )) {
|
||||
classesByName.emplace( className,
|
||||
std::make_unique< Class >( currentlyConstructedClass, classesById.size(), className ) );
|
||||
std::make_unique< Class >( currentlyConstructedClass, index, className ) );
|
||||
auto *const klass= classesByName.at( className ).get();
|
||||
classesById.push_back( klass );
|
||||
classesById[ klass->id ]= klass;
|
||||
*classId = klass->id;
|
||||
}
|
||||
Class *const klass = classesByName.at( className ).get();
|
||||
@ -99,7 +99,7 @@ void IdentifiableObject::registerName (const char *className, int *classId)
|
||||
* \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 (int otherClassId)
|
||||
bool IdentifiableObject::instanceOf (std::intptr_t otherClassId)
|
||||
{
|
||||
if (otherClassId == -1)
|
||||
// Other class has not been registered yet, while it should have been,
|
||||
|
||||
Reference in New Issue
Block a user