|
OMNeT++ API 6.1
Discrete Event Simulation Library
|
|
16 #ifndef __OMNETPP_CHECKANDCAST_H
17 #define __OMNETPP_CHECKANDCAST_H
20 #include "simkerneldefs.h"
21 #include "cownedobject.h"
22 #include "cexception.h"
24 #include "csimulation.h"
28 template<
class P,
class T>
29 void check_and_cast_failure(T *p, P ret)
31 const cObject *o =
dynamic_cast<const cObject *
>(p);
33 throw cRuntimeError(
"check_and_cast(): Cannot cast (%s*)%s to type '%s'",
38 throw cRuntimeError(
"check_and_cast(): Cannot cast '%s*' to type '%s'",
60 template<
class P,
class T>
65 P ret =
dynamic_cast<P
>(p);
67 check_and_cast_failure(p, ret);
76 template<
class P,
class T>
81 P ret =
dynamic_cast<P
>(p);
83 check_and_cast_failure(p, ret);
cModule * getContextModule() const
virtual const char * getFullName() const override
P check_and_cast_nullable(T *p)
A variant of check_and_cast<>() that also allows nullptr as input.
Definition: checkandcast.h:77
P check_and_cast(T *p)
Cast a pointer to the given pointer type P, and throw exception if fails.
Definition: checkandcast.h:61
Thrown when the simulation kernel or other components detect a runtime error.
Definition: cexception.h:286
static cSimulation * getActiveSimulation()
Definition: csimulation.h:148
const SIM_API char * opp_typename(const std::type_info &t)
Returns the name of a C++ type, correcting the quirks of various compilers.