diff --git a/src/OpenFOAM/db/typeInfo/className.H b/src/OpenFOAM/db/typeInfo/className.H index 01fef3e949..c46c3d9ba1 100644 --- a/src/OpenFOAM/db/typeInfo/className.H +++ b/src/OpenFOAM/db/typeInfo/className.H @@ -52,7 +52,7 @@ Description inline const char* typeName_() { return TypeNameString; } \ extern const ::Foam::word typeName; -//- Add typeName information from argument @a TypeNameString to a template class. +//- Add typeName information from argument @a TemplateNameString to a template class. // Without debug information. #define TemplateNameNoDebug(TemplateNameString) \ class TemplateNameString##Name \ @@ -189,68 +189,6 @@ public: \ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#if 0 // PREVIOUS DEFINITIONS - -//- Adds typeName information from its argument @a TypeNameString to a class -#define ClassName(TypeNameString) \ - static const char* typeName_() { return TypeNameString; } \ - static const ::Foam::word typeName; \ - static int debug - -#define NamespaceName(TypeNameString) \ - inline const char* typeName_() { return TypeNameString; } \ - extern const ::Foam::word typeName; \ - extern int debug - -#define TemplateName(template) \ -class template##Name \ -{ \ -public: \ - \ - template##Name() \ - {} \ - \ - ClassName(#template); \ -}; - - -#define defineTypeNameAndDebug(Type, DebugSwitch) \ - const ::Foam::word Type::typeName(Type::typeName_()); \ - int Type::debug(::Foam::debug::debugSwitch(Type::typeName_(), DebugSwitch)); - -#ifdef __INTEL_COMPILER -#define defineTemplateTypeNameAndDebugWithName(Type, Name, DebugSwitch) \ - const ::Foam::word Type::typeName(Name); \ - int Type::debug(::Foam::debug::debugSwitch(Name, DebugSwitch)); -#else -#define defineTemplateTypeNameAndDebugWithName(Type, Name, DebugSwitch) \ - template<> \ - const ::Foam::word Type::typeName(Name); \ - template<> \ - int Type::debug(::Foam::debug::debugSwitch(Name, DebugSwitch)); -#endif - -#define defineTemplateTypeNameAndDebug(Type, DebugSwitch) \ - defineTemplateTypeNameAndDebugWithName(Type, #Type, DebugSwitch); - -#ifdef __INTEL_COMPILER -#define defineNamedTemplateTypeNameAndDebug(Type, DebugSwitch) \ - const ::Foam::word Type::typeName(Type::typeName_()); \ - int Type::debug(::Foam::debug::debugSwitch(Type::typeName_(), DebugSwitch)); -#else -#define defineNamedTemplateTypeNameAndDebug(Type, DebugSwitch) \ - template<> \ - const ::Foam::word Type::typeName(Type::typeName_()); \ - template<> \ - int Type::debug(::Foam::debug::debugSwitch(Type::typeName_(), DebugSwitch)); -#endif - -#endif // OLD DEFINITIONS - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #endif // ************************************************************************* // diff --git a/src/OpenFOAM/db/typeInfo/typeInfo.H b/src/OpenFOAM/db/typeInfo/typeInfo.H index 4bef5db9e2..88320bcfe1 100644 --- a/src/OpenFOAM/db/typeInfo/typeInfo.H +++ b/src/OpenFOAM/db/typeInfo/typeInfo.H @@ -60,12 +60,14 @@ Description // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// declarations for use in header files +// declarations (for use in header files) +//- Declare a ClassNameNoDebug() with extra virtual type info #define TypeNameNoDebug(TypeNameString) \ ClassNameNoDebug(TypeNameString); \ virtual const word& type() const { return typeName; } +//- Declare a ClassName() with extra virtual type info #define TypeName(TypeNameString) \ ClassName(TypeNameString); \ virtual const word& type() const { return typeName; } @@ -78,9 +80,8 @@ namespace Foam // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // -// Reference type cast template function wraps dynamic_cast to handle the -// bad_cast exception and generate a FatalError. - +//- Reference type cast template function, +// wraps dynamic_cast to handle bad_cast exception and generate a FatalError. template inline To& dynamicCast(From& r) { @@ -100,6 +101,8 @@ inline To& dynamicCast(From& r) } +//- Reference type cast template function. +// As per dynamicCast, but handles type names via the virtual type() method. template inline To& refCast(From& r) { @@ -119,6 +122,7 @@ inline To& refCast(From& r) } +//- Check the typeid template inline bool isType(const Type& t) { @@ -126,6 +130,7 @@ inline bool isType(const Type& t) } +//- Check if a dynamic_cast to typeid is possible template inline bool isA(const Type& t) {