OMNeT++ Simulation Library
5.6.1
|
This group is a collection of classes and functions that make it easier to write simulation models.
Classes | |
class | cMatchExpression::Matchable |
Objects to be matched must implement this interface. More... | |
class | cMatchExpression |
Decides whether an object matches an expression. More... | |
class | cMatchableString |
Wrapper to make a string matchable with cMatchExpression. More... | |
class | cPatternMatcher |
Glob-style pattern matching class, adopted to special OMNeT++ requirements. One instance represents a pattern to match. More... | |
class | cStringTokenizer |
String tokenizer class, modelled after strtok(). More... | |
class | cTopology |
Routing support. The cTopology class was designed primarily to support routing in telecommunication or multiprocessor networks. More... | |
class | opp_string |
Lightweight string class, used internally in some parts of OMNeT++. More... | |
class | opp_string_vector |
Lightweight string vector, used internally in some parts of OMNeT++. More... | |
class | opp_string_map |
Lightweight string-to-string map, used internally in some parts of OMNeT++. More... | |
Functions | |
template<class P , class T > | |
P | check_and_cast (T *p) |
Cast a pointer to the given pointer type P, and throw exception if fails. More... | |
template<class P , class T > | |
P | check_and_cast_nullable (T *p) |
A variant of check_and_cast<>() that also allows nullptr as input. More... | |
template<typename ToInt , typename FromInt > | |
ToInt | checked_int_cast (FromInt x, const char *errmsg=nullptr) |
Safe integer cast: it throws an exception if in case of an overflow, i.e. when if the target type cannot represent the value in the source type. The context argument will be used for the error message. More... | |
template<typename ToInt , typename FromInt > | |
ToInt | checked_int_cast (FromInt x, const cObject *context, const char *errmsg=nullptr) |
Safe integer cast: it throws an exception if in case of an overflow, i.e. when if the target type cannot represent the value in the source type. The context argument will be used for the error message. More... | |
template<typename ToInt > | |
ToInt | checked_int_cast (double d, const char *errmsg=nullptr) |
Safe integer cast: it throws an exception if in case of an overflow, i.e. when if the target type cannot represent the value in the source type. The context argument will be used for the error message. More... | |
int | opp_strlen (const char *) |
Same as the standard strlen() function, except that it also accepts nullptr and returns 0 for it. More... | |
char * | opp_strdup (const char *) |
Duplicates the string, using new char[] . For nullptr and empty strings it returns nullptr. More... | |
char * | opp_strcpy (char *, const char *) |
Same as the standard strcpy() function, except that nullptr as the second argument is treated as an empty string (""). More... | |
int | opp_strcmp (const char *, const char *) |
Same as the standard strcmp() function, except that nullptr is treated exactly as an empty string (""). More... | |
SIM_API char * | opp_strprettytrunc (char *dest, const char *src, unsigned maxlen) |
Copies src string into dest, and if its length would exceed maxlen, it is truncated with an ellipsis. For example, opp_strprettytrunc(buf, "long-long",6) yields "lon..." . More... | |
SIM_API const char * | opp_typename (const std::type_info &t) |
Returns the name of a C++ type, correcting the quirks of various compilers. More... | |
SIM_API int64_t | opp_get_monotonic_clock_nsecs () |
Returns a monotonic time in nanoseconds since some unspecified starting point. This clock is not affected by discontinuous jumps in the system time (e.g. if the system administrator manually changes the clock). Note that the actual resolution (precision) of the clock may be less than nanoseconds. More... | |
SIM_API int64_t | opp_get_monotonic_clock_usecs () |
Returns a monotonic time in microseconds since some unspecified starting point. This clock is not affected by discontinuous jumps in the system time (e.g. if the system administrator manually changes the clock). Note that the actual resolution (precision) of the clock may be less than microseconds. More... | |
P omnetpp::check_and_cast | ( | T * | p | ) |
Cast a pointer to the given pointer type P, and throw exception if fails.
The method calls dynamic_cast<P>(p) where P is a type you supplied; if the result is nullptr (which indicates incompatible types), an exception is thrown.
In the following example, DHCPPacket is a subclass of cMessage, and we want to assert that the message received is actually a DHCPPacket. If not, the simulation stops with an error message as the result of the exception.
cMessage *msg = ...; DHCPPacket *pk = check_and_cast<DHCPPacket *>(msg);
References omnetpp::opp_typename().
P omnetpp::check_and_cast_nullable | ( | T * | p | ) |
A variant of check_and_cast<>() that also allows nullptr as input.
ToInt omnetpp::checked_int_cast | ( | FromInt | x, |
const char * | errmsg = nullptr |
||
) |
Safe integer cast: it throws an exception if in case of an overflow, i.e. when if the target type cannot represent the value in the source type. The context argument will be used for the error message.
Referenced by cNedValue::operator char(), cPar::operator char(), cNedValue::operator int(), cPar::operator int(), cNedValue::operator long(), cPar::operator long(), cNedValue::operator long long(), cPar::operator long long(), cNedValue::operator short(), cPar::operator short(), cNedValue::operator unsigned char(), cPar::operator unsigned char(), cNedValue::operator unsigned int(), cPar::operator unsigned int(), cNedValue::operator unsigned long(), cPar::operator unsigned long(), cNedValue::operator unsigned long long(), cPar::operator unsigned long long(), cNedValue::operator unsigned short(), cPar::operator unsigned short(), and cNedValue::operator=().
ToInt omnetpp::checked_int_cast | ( | FromInt | x, |
const cObject * | context, | ||
const char * | errmsg = nullptr |
||
) |
Safe integer cast: it throws an exception if in case of an overflow, i.e. when if the target type cannot represent the value in the source type. The context argument will be used for the error message.
ToInt omnetpp::checked_int_cast | ( | double | d, |
const char * | errmsg = nullptr |
||
) |
Safe integer cast: it throws an exception if in case of an overflow, i.e. when if the target type cannot represent the value in the source type. The context argument will be used for the error message.
|
inline |
Same as the standard strlen() function, except that it also accepts nullptr and returns 0 for it.
|
inline |
Duplicates the string, using new char[]
. For nullptr and empty strings it returns nullptr.
Referenced by opp_string::operator=(), and opp_string::opp_string().
|
inline |
Same as the standard strcpy() function, except that nullptr as the second argument is treated as an empty string ("").
|
inline |
Same as the standard strcmp() function, except that nullptr is treated exactly as an empty string ("").
Referenced by cObject::isName(), opp_string::operator!=(), opp_string::operator<(), and opp_string::operator==().
SIM_API char* omnetpp::opp_strprettytrunc | ( | char * | dest, |
const char * | src, | ||
unsigned | maxlen | ||
) |
Copies src string into dest, and if its length would exceed maxlen, it is truncated with an ellipsis. For example, opp_strprettytrunc(buf, "long-long",6)
yields "lon..."
.
SIM_API const char* omnetpp::opp_typename | ( | const std::type_info & | t | ) |
Returns the name of a C++ type, correcting the quirks of various compilers.
Referenced by omnetpp::check_and_cast(), cGenericReadonlyWatch< T >::getClassName(), and cGenericAssignableWatch< T >::getClassName().
SIM_API int64_t omnetpp::opp_get_monotonic_clock_nsecs | ( | ) |
Returns a monotonic time in nanoseconds since some unspecified starting point. This clock is not affected by discontinuous jumps in the system time (e.g. if the system administrator manually changes the clock). Note that the actual resolution (precision) of the clock may be less than nanoseconds.
SIM_API int64_t omnetpp::opp_get_monotonic_clock_usecs | ( | ) |
Returns a monotonic time in microseconds since some unspecified starting point. This clock is not affected by discontinuous jumps in the system time (e.g. if the system administrator manually changes the clock). Note that the actual resolution (precision) of the clock may be less than microseconds.