54 #ifndef Foam_typeInfo_H 55 #define Foam_typeInfo_H 66 #define TypeNameNoDebug(TypeNameString) \ 67 ClassNameNoDebug(TypeNameString); \ 68 virtual const word& type() const { return typeName; } 71 #define TypeName(TypeNameString) \ 72 ClassName(TypeNameString); \ 73 virtual const word& type() const { return typeName; } 85 template<
class Type,
class U>
86 inline const Type*
isA(
const U& obj)
89 return dynamic_cast<const Type*
>(
p);
94 template<
class Type,
class U>
95 inline bool isType(
const U& obj)
97 return typeid(Type) ==
typeid(obj);
102 template<
class Type,
class U>
106 Type* casted =
dynamic_cast<Type*
>(
p);
111 <<
"Attempt to cast type " <<
typeid(
U).
name()
112 <<
" to type " <<
typeid(Type).
name()
121 template<
class Type,
class U>
125 Type* casted =
dynamic_cast<Type*
>(
p);
130 <<
"Attempt to cast type " <<
typeid(
U).
name()
131 <<
" to type " <<
typeid(Type).
name()
141 template<
class Type,
class U>
145 Type* casted =
dynamic_cast<Type*
>(
p);
150 <<
"Attempt to cast type " << obj.type()
151 <<
" to type " << Type::typeName
161 template<
class Type,
class U>
165 Type* casted =
dynamic_cast<Type*
>(
p);
170 <<
"Attempt to cast type " << obj.type()
171 <<
" to type " << Type::typeName
182 template<
class Type,
class U>
183 inline Type&
refCast(
U& obj,
const label index)
186 Type* casted =
dynamic_cast<Type*
>(
p);
191 <<
"Attempt to cast type " << obj.type()
192 <<
" to type " << Type::typeName
193 <<
" at index " << index
208 return isA<Type, U>(obj);
220 return isType<Type, U>(obj);
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Type & refCast(U &obj)
A dynamic_cast (for references) that generates FatalError on failed casts, uses the virtual type() me...
bool operator()(const U &obj) const
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
bool isType(const U &obj)
Check if typeid of the object and Type are identical.
errorManip< error > abort(error &err)
Type & dynamicCast(U &obj)
A dynamic_cast (for references) that generates FatalError on failed casts.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Macro definitions for declaring ClassName(), NamespaceName(), etc.
const Type * isA(const U &obj)
Check if dynamic_cast to Type is possible.
bool operator()(const U &obj) const
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...