59 #include <type_traits>
67 #define TypeNameNoDebug(TypeNameString) \
68 ClassNameNoDebug(TypeNameString); \
69 virtual const word& type() const { return typeName; } \
70 template<class Name> \
71 word typedName(Name name) const { return (type() + ':') + name; }
74 #define TypeName(TypeNameString) \
75 ClassName(TypeNameString); \
76 virtual const word& type() const { return typeName; } \
77 template<class Name> \
78 word typedName(Name name) const { return (type() + ':') + name; }
90 template<
class To,
class From>
95 return dynamic_cast<To&
>(r);
97 catch (
const std::bad_cast&)
100 <<
"Attempt to cast type " <<
typeid(r).
name()
101 <<
" to type " <<
typeid(To).
name()
104 return dynamic_cast<To&
>(r);
112 template<
class To,
class From>
117 return NullObjectNonConstRef<To>();
122 return dynamic_cast<To&
>(r);
124 catch (
const std::bad_cast&)
126 return NullObjectNonConstRef<To>();
133 template<
class To,
class From>
138 return dynamic_cast<To&
>(r);
140 catch (
const std::bad_cast&)
143 <<
"Attempt to cast type " << r.type()
144 <<
" to type " << To::typeName
147 return dynamic_cast<To&
>(r);
154 template<
class To,
class From>
157 return dynamicCastNull<To, From>(r);
162 template<
class TestType,
class Type>
165 return typeid(t) ==
typeid(TestType);
170 template<
class TestType,
class Type>
171 inline bool isA(
const Type& t)
173 const Type* tPtr = &t;
174 return dynamic_cast<const TestType*
>(tPtr);
180 template<
class TypeName,
class Name>
183 return (TypeName::typeName +
':') +
name;
189 constexpr
bool isRef = std::is_reference<Type>::value;
A class for handling words, derived from string.
Macro definitions for declaring ClassName(), NamespaceName(), etc.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
To & refCastNull(From &r)
Reference type cast template function,.
To & refCast(From &r)
Reference type cast template function.
errorManip< error > abort(error &err)
bool isType(const Type &t)
Check the typeid.
To & dynamicCast(From &r)
Reference type cast template function,.
bool isA(const Type &t)
Check if a dynamic_cast to typeid is possible.
constexpr bool isRef
Determine whether a type is a reference.
word typedName(Name name)
Return the name of the object within the given type.
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
bool isNull(const T &t)
Return true if t is a reference to the nullObject of type T.
To & dynamicCastNull(From &r)
Reference type cast template function,.