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; }
81 #define FunctionTypeName(TypeNameString) \
82 FunctionName(TypeNameString); \
83 virtual const word& type() const { return typeName; } \
84 template<class Name> \
85 word typedName(Name name) const { return (type() + ':') + name; }
97 template<
class To,
class From>
102 return dynamic_cast<To&
>(r);
104 catch (
const std::bad_cast&)
107 <<
"Attempt to cast type " <<
typeid(r).
name()
108 <<
" to type " <<
typeid(To).
name()
111 return dynamic_cast<To&
>(r);
119 template<
class To,
class From>
124 return NullObjectNonConstRef<To>();
129 return dynamic_cast<To&
>(r);
131 catch (
const std::bad_cast&)
133 return NullObjectNonConstRef<To>();
140 template<
class To,
class From>
145 return dynamic_cast<To&
>(r);
147 catch (
const std::bad_cast&)
150 <<
"Attempt to cast type " << r.type()
154 return dynamic_cast<To&
>(r);
161 template<
class To,
class From>
164 return dynamicCastNull<To, From>(r);
169 template<
class TestType,
class Type>
172 return typeid(t) ==
typeid(TestType);
177 template<
class TestType,
class Type>
178 inline bool isA(
const Type& t)
180 const Type* tPtr = &t;
181 return dynamic_cast<const TestType*
>(tPtr);
187 template<
class TypeName,
class Name>
196 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.
String typeName(const std::type_info &info)
Return the un-mangled name given the standard type info.
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,.