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; } 86 template<
class Type,
class U>
87 inline const Type*
isA(
const U& obj)
90 return dynamic_cast<const Type*
>(
p);
95 template<
class Type,
class U>
96 inline bool isType(
const U& obj)
98 return typeid(Type) ==
typeid(obj);
104 template<
class Type,
class U>
108 Type* casted =
dynamic_cast<Type*
>(
p);
113 <<
"Attempt to cast type " <<
typeid(
U).
name()
114 <<
" to type " <<
typeid(Type).
name()
124 template<
class Type,
class U>
128 Type* casted =
dynamic_cast<Type*
>(
p);
133 <<
"Attempt to cast type " <<
typeid(
U).
name()
134 <<
" to type " <<
typeid(Type).
name()
146 template<
class Type,
class U>
150 Type* casted =
dynamic_cast<Type*
>(
p);
155 <<
"Attempt to cast type " << obj.type()
156 <<
" to type " << Type::typeName
167 template<
class Type,
class U>
171 Type* casted =
dynamic_cast<Type*
>(
p);
176 <<
"Attempt to cast type " << obj.type()
177 <<
" to type " << Type::typeName
189 template<
class Type,
class U>
190 inline Type&
refCast(
U& obj,
const label index)
193 Type* casted =
dynamic_cast<Type*
>(
p);
198 <<
"Attempt to cast type " << obj.type()
199 <<
" to type " << Type::typeName
200 <<
" at index " << index
215 return isA<Type, U>(obj);
227 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). Generates a FatalError on failed casts and uses the virtual type() m...
bool operator()(const U &obj) const
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::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.
Test if dynamic_cast to Type is possible, as a functor.
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 ...