diff --git a/lout/identity.cc b/lout/identity.cc index 7ba57c6..437bba0 100644 --- a/lout/identity.cc +++ b/lout/identity.cc @@ -58,8 +58,9 @@ void IdentifiableObject::Class::intoStringBuffer(misc::StringBuffer *sb) HashTable *IdentifiableObject::classesByName = new HashTable (true, true); -Vector *IdentifiableObject::classesById = - new Vector (16, false); + +std::vector< IdentifiableObject::Class * > IdentifiableObject::classesById; + IdentifiableObject::Class *IdentifiableObject::currentlyConstructedClass; IdentifiableObject::IdentifiableObject () @@ -85,11 +86,11 @@ void IdentifiableObject::registerName (const char *className, int *classId) ConstString str (className); Class *klass = classesByName->get (&str); if (klass == NULL) { - klass = new Class (currentlyConstructedClass, classesById->size (), + klass = new Class (currentlyConstructedClass, classesById.size (), className); ConstString *key = new ConstString (className); classesByName->put (key, klass); - classesById->put (klass); + classesById.push_back (klass); *classId = klass->id; } @@ -109,7 +110,7 @@ bool IdentifiableObject::instanceOf (int otherClassId) // if this class is an instance of it or of a sub-class. return false; - Class *otherClass = classesById->get (otherClassId); + Class *otherClass = classesById.at (otherClassId); if (otherClass == NULL) { fprintf (stderr, @@ -118,7 +119,7 @@ bool IdentifiableObject::instanceOf (int otherClassId) return false; } - for (Class *klass = classesById->get (classId); klass != NULL; + for (Class *klass = classesById.at (classId); klass != NULL; klass = klass->parent) { if (klass == otherClass) return true; diff --git a/lout/identity.hh b/lout/identity.hh index 5a3025d..084acf3 100644 --- a/lout/identity.hh +++ b/lout/identity.hh @@ -98,7 +98,7 @@ namespace identity { class IdentifiableObject: public object::Object { private: - class Class: public object::Object + class Class final: public object::Object { public: Class *parent; @@ -112,7 +112,7 @@ private: static container::typed::HashTable *classesByName; - static container::typed::Vector *classesById; + static std::vector< Class * > classesById; static Class *currentlyConstructedClass; int classId; @@ -137,7 +137,7 @@ public: * \brief Return the name, under which the class of this object was * registered. */ - const char *getClassName() { return classesById->get(classId)->className; } + const char *getClassName() { return classesById.at( classId )->className; } bool instanceOf (int otherClassId); };