2016-09-27 22:01:08 +03:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2016-06-12 23:46:03 +03:00
|
|
|
#ifndef cmTypeMacro_h
|
|
|
|
#define cmTypeMacro_h
|
|
|
|
|
|
|
|
// All subclasses of cmCommand or cmCTestGenericHandler should
|
|
|
|
// invoke this macro.
|
|
|
|
#define cmTypeMacro(thisClass, superclass) \
|
2016-06-29 10:31:51 +03:00
|
|
|
const char* GetNameOfClass() CM_OVERRIDE { return #thisClass; } \
|
2016-06-12 23:46:03 +03:00
|
|
|
typedef superclass Superclass; \
|
|
|
|
static bool IsTypeOf(const char* type) \
|
|
|
|
{ \
|
|
|
|
if (!strcmp(#thisClass, type)) { \
|
|
|
|
return true; \
|
|
|
|
} \
|
|
|
|
return Superclass::IsTypeOf(type); \
|
|
|
|
} \
|
2016-06-29 10:31:51 +03:00
|
|
|
bool IsA(const char* type) CM_OVERRIDE \
|
|
|
|
{ \
|
|
|
|
return thisClass::IsTypeOf(type); \
|
|
|
|
} \
|
2016-06-12 23:46:03 +03:00
|
|
|
static thisClass* SafeDownCast(cmObject* c) \
|
|
|
|
{ \
|
|
|
|
if (c && c->IsA(#thisClass)) { \
|
|
|
|
return static_cast<thisClass*>(c); \
|
|
|
|
} \
|
|
|
|
return 0; \
|
|
|
|
} \
|
|
|
|
class cmTypeMacro_UseTrailingSemicolon
|
|
|
|
|
|
|
|
#endif
|