Base: Use constant for Type::BadType instead Type::badType()
This commit is contained in:
@@ -37,8 +37,8 @@ using namespace Base;
|
||||
struct Base::TypeData
|
||||
{
|
||||
TypeData(const char* theName,
|
||||
const Type type = Type::badType(),
|
||||
const Type theParent = Type::badType(),
|
||||
const Type type = Type::BadType,
|
||||
const Type theParent = Type::BadType,
|
||||
Type::instantiationMethod method = nullptr)
|
||||
: name(theName)
|
||||
, parent(theParent)
|
||||
@@ -56,6 +56,8 @@ std::map<std::string, unsigned int> Type::typemap;
|
||||
std::vector<TypeData*> Type::typedata;
|
||||
std::set<std::string> Type::loadModuleSet;
|
||||
|
||||
const Type Type::BadType;
|
||||
|
||||
void* Type::createInstance() const
|
||||
{
|
||||
instantiationMethod method = typedata[index]->instMethod;
|
||||
@@ -77,7 +79,7 @@ void* Type::createInstanceByName(const char* TypeName, bool bLoadModule)
|
||||
|
||||
// now the type should be in the type map
|
||||
Type type = fromName(TypeName);
|
||||
if (type == badType()) {
|
||||
if (type == BadType) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -117,13 +119,6 @@ std::string Type::getModuleName(const char* ClassName)
|
||||
: std::string();
|
||||
}
|
||||
|
||||
Type Type::badType()
|
||||
{
|
||||
Type bad;
|
||||
bad.index = 0;
|
||||
return bad;
|
||||
}
|
||||
|
||||
|
||||
Type Type::createType(const Type& parent, const char* name, instantiationMethod method)
|
||||
{
|
||||
@@ -167,7 +162,7 @@ Type Type::fromName(const char* name)
|
||||
return typedata[pos->second]->type;
|
||||
}
|
||||
|
||||
return Type::badType();
|
||||
return Type::BadType;
|
||||
}
|
||||
|
||||
Type Type::fromKey(unsigned int key)
|
||||
@@ -176,7 +171,7 @@ Type Type::fromKey(unsigned int key)
|
||||
return typedata[key]->type;
|
||||
}
|
||||
|
||||
return Type::badType();
|
||||
return BadType;
|
||||
}
|
||||
|
||||
const char* Type::getName() const
|
||||
@@ -198,7 +193,7 @@ bool Type::isDerivedFrom(const Type& type) const
|
||||
return true;
|
||||
}
|
||||
temp = temp.getParent();
|
||||
} while (temp != badType());
|
||||
} while (!temp.isBad());
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -233,5 +228,5 @@ Type Type::getTypeIfDerivedFrom(const char* name, const Type& parent, bool bLoad
|
||||
return type;
|
||||
}
|
||||
|
||||
return Type::badType();
|
||||
return BadType;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user