53 #ifndef Foam_typeInfo_H 54 #define Foam_typeInfo_H 65 #define TypeNameNoDebug(TypeNameString) \ 66 ClassNameNoDebug(TypeNameString); \ 67 virtual const word& type() const { return typeName; } 70 #define TypeName(TypeNameString) \ 71 ClassName(TypeNameString); \ 72 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);
96 template<
class Type,
class U>
100 return const_cast<Type*
>(
dynamic_cast<const Type*
>(
p));
105 template<
class Type,
class U>
106 inline bool isType(
const U& obj)
108 return typeid(Type) ==
typeid(obj);
114 template<
class Type,
class U>
118 Type* casted =
dynamic_cast<Type*
>(
p);
123 <<
"Attempt to cast type " <<
typeid(
U).
name()
124 <<
" to type " <<
typeid(Type).
name()
134 template<
class Type,
class U>
138 Type* casted =
dynamic_cast<Type*
>(
p);
143 <<
"Attempt to cast type " <<
typeid(
U).
name()
144 <<
" to type " <<
typeid(Type).
name()
156 template<
class Type,
class U>
160 Type* casted =
dynamic_cast<Type*
>(
p);
165 <<
"Attempt to cast type " << obj.type()
166 <<
" to type " << Type::typeName
179 template<
class Type,
class U>
183 const Type* casted =
dynamic_cast<const Type*
>(
p);
188 <<
"Attempt to cast type " << obj.type()
189 <<
" to type " << Type::typeName
193 return const_cast<Type&
>(*casted);
200 template<
class Type,
class U>
204 Type* casted =
dynamic_cast<Type*
>(
p);
209 <<
"Attempt to cast type " << obj.type()
210 <<
" to type " << Type::typeName
222 template<
class Type,
class U>
223 inline Type&
refCast(
U& obj,
const label index)
226 Type* casted =
dynamic_cast<Type*
>(
p);
231 <<
"Attempt to cast type " << obj.type()
232 <<
" to type " << Type::typeName
233 <<
" at index " << index
250 return isA<Type, U>(obj);
262 return isType<Type, U>(obj);
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
Type * isA_constCast(const U &obj)
Attempt dynamic_cast to Type followed by a const_cast of the result.
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.
Type & refConstCast(const U &obj)
A dynamic_cast (for const references) to Type reference, followed by a const_cast of the result...
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Macro definitions for declaring ClassName(), NamespaceName(), etc.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
bool operator()(const U &obj) const
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...