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; }
85template<
class Type,
class U>
86inline const Type*
isA(
const U& obj)
89 return dynamic_cast<const Type*
>(
p);
96template<
class Type,
class U>
100 return const_cast<Type*
>(
dynamic_cast<const Type*
>(
p));
105template<
class Type,
class U>
106inline bool isType(
const U& obj)
108 return typeid(Type) ==
typeid(obj);
114template<
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()
134template<
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()
156template<
class Type,
class U>
160 Type* casted =
dynamic_cast<Type*
>(
p);
165 <<
"Attempt to cast type " << obj.type()
166 <<
" to type " << Type::typeName
179template<
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);
200template<
class Type,
class U>
204 Type* casted =
dynamic_cast<Type*
>(
p);
209 <<
"Attempt to cast type " << obj.type()
210 <<
" to type " << Type::typeName
222template<
class Type,
class U>
223inline 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
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Macro definitions for declaring ClassName(), NamespaceName(), etc.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
Type * isA_constCast(const U &obj)
Attempt dynamic_cast to Type followed by a const_cast of the result.
errorManip< error > abort(error &err)
Type & dynamicCast(U &obj)
A dynamic_cast (for references) that generates FatalError on failed casts.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
bool isType(const U &obj)
Check if typeid of the object and Type are identical.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
Type & refConstCast(const U &obj)
A dynamic_cast (for const references) to Type reference, followed by a const_cast of the result.
Test if dynamic_cast to Type is possible, as a functor.
bool operator()(const U &obj) const
Test if typeid is identical to the Type, as a functor.
bool operator()(const U &obj) const