Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

Functions


Connecting gates.

class class class class class
class SIM_API void 
connect (cModule *frm, int frg, cChannelType *linkp, cModule *tom, int tog)
SIM_API void connect (cModule *frm, int frg, cPar *delayp, cPar *errorp, cPar *dataratep, cModule *tom, int tog)

Miscellaneous functions.

SIM_API cPolymorphiccreateOne (const char *classname)
SIM_API cPolymorphiccreateOneIfClassIsKnown (const char *classname)

Finding global objects by name.

SIM_API cNetworkTypefindNetwork (const char *s)
SIM_API cModuleTypefindModuleType (const char *s)
SIM_API cModuleInterfacefindModuleInterface (const char *s)
SIM_API cChannelTypefindChannelType (const char *s)
SIM_API cLinkTypefindLink (const char *s)
SIM_API cFunctionTypefindFunction (const char *s, int argcount)
SIM_API cEnumfindEnum (const char *s)

Converting simulation time to and from string form.

SIM_API simtime_t strToSimtime (const char *str)
SIM_API simtime_t strToSimtime0 (const char *&str)
SIM_API char * simtimeToStr (simtime_t t, char *dest=NULL)
SIM_API char * simtimeToStrShort (simtime_t t, char *buf=NULL)

Utility functions to support nedtool-compiled expressions.

SIM_API double min (double a, double b)
SIM_API double max (double a, double b)
SIM_API double bool_and (double a, double b)
SIM_API double bool_or (double a, double b)
SIM_API double bool_xor (double a, double b)
SIM_API double bool_not (double a)
SIM_API double bin_and (double a, double b)
SIM_API double bin_or (double a, double b)
SIM_API double bin_xor (double a, double b)
SIM_API double bin_compl (double a)
SIM_API double shift_left (double a, double b)
SIM_API double shift_right (double a, double b)

String-related utility functions.

Some of these functions are similar to <string.h> functions, with the exception that they also accept NULL pointers as empty strings (""), and use operator new instead of malloc().

It is recommended to use these functions instead of the original <string.h> functions.

SIM_API char * opp_strdup (const char *)
SIM_API char * opp_strcpy (char *, const char *)
SIM_API int opp_strcmp (const char *, const char *)
SIM_API bool opp_strmatch (const char *, const char *)
SIM_API int opp_strlen (const char *)
SIM_API char * opp_mkindexedname (char *dest, const char *name, int index)
SIM_API char * opp_concat (const char *s1, const char *s2, const char *s3=NULL, const char *s4=NULL)
SIM_API char * opp_strprettytrunc (char *dest, const char *src, unsigned maxlen)
const char * correct (const char *)

Miscellaneous functions.

bool equal (double a, double b, double epsilon)

Functions

template<class T>
check_and_cast (cPolymorphic *p)


Function Documentation

SIM_API double bin_and double  a,
double  b
 

Returns the binary AND of a and b.

(a and b are converted to unsigned long for the operation.)

SIM_API double bin_compl double  a  ) 
 

Returns the bitwise negation (unary complement) of a.

(a is converted to unsigned long for the operation.)

SIM_API double bin_or double  a,
double  b
 

Returns the binary OR of a and b.

(a and b are converted to unsigned long for the operation.)

SIM_API double bin_xor double  a,
double  b
 

Returns the binary exclusive OR of a and b.

(a and b are converted to unsigned long for the operation.)

SIM_API double bool_and double  a,
double  b
 

Returns the boolean AND of a and b.

(Any nonzero number is treated as true.)

SIM_API double bool_not double  a  ) 
 

Returns the boolean negation of a.

(Any nonzero number is treated as true.)

SIM_API double bool_or double  a,
double  b
 

Returns the boolean OR of a and b.

(Any nonzero number is treated as true.)

SIM_API double bool_xor double  a,
double  b
 

Returns the boolean Exclusive OR of a and b.

(Any nonzero number is treated as true.)

template<class T>
T check_and_cast cPolymorphic p  ) 
 

Cast an object pointer to the given C++ type and throw exception if fails.

The method calls dynamic_cast<T>(p) where T is a type you supplied; if the result is NULL (which indicates incompatible types), an exception is thrown.

In the following example, MyPacket is a subclass of cMessage, and we want to assert that the message received is actually a MyPacket. If not, the simulation stops with an error message as the result of the exception.

   cMessage *msg = receive();
   MyPacket *pkt = check_and_cast<MyPacket *>(msg);
 

SIM_API void connect cModule frm,
int  frg,
cPar delayp,
cPar errorp,
cPar dataratep,
cModule tom,
int  tog
 

DEPRECATED: use cGate::connectTo() instead.

Connects two gates.

class class class class class class class SIM_API void connect cModule frm,
int  frg,
cChannelType linkp,
cModule tom,
int  tog
 

DEPRECATED: use cGate::connectTo() instead.

Connects two gates.

const char * correct const char *   )  [inline]
 

Returns the pointer passed as argument unchanged, except that if it was NULL, it returns a pointer to a null string ("").

SIM_API cPolymorphic* createOne const char *  classname  ) 
 

Creates an instance of a particular class; the result has to be cast to the appropriate type by hand.

The class must have been registered previously with the Register_Class() macro. This function internally relies on the cClassRegister class.

If the class is not registered, this function throws an exception. If you'd prefer having a NULL pointer returned instead, use the createOneIfClassIsKnown() function.

Example:

cObject *param = createOne( "cPar" );

createOne() is used e.g. in parallel simulation when an object is received from another partition and it has to be demarshalled.

See also:
createOneIfClassIsKnown()

Register_Class() macro

cClassRegister class

SIM_API cPolymorphic* createOneIfClassIsKnown const char *  classname  ) 
 

A variant of the createOne() function; this function doesn't throw an exception if the class is not registered, but returns a NULL pointer instead.

See also:
createOne()

bool equal double  a,
double  b,
double  epsilon
[inline]
 

Tests equality of two doubles, with the given precision.

SIM_API cChannelType* findChannelType const char *  s  ) 
 

Find a cChannelType.

SIM_API cEnum* findEnum const char *  s  ) 
 

Find a cEnum.

SIM_API cFunctionType* findFunction const char *  s,
int  argcount
 

Find a cFunctionType.

SIM_API cLinkType* findLink const char *  s  ) 
 

DEPRECATED.

SIM_API cModuleInterface* findModuleInterface const char *  s  ) 
 

Find a cModuleInterface.

SIM_API cModuleType* findModuleType const char *  s  ) 
 

Find a cModuleType.

SIM_API cNetworkType* findNetwork const char *  s  ) 
 

Find a cNetworkType.

SIM_API double max double  a,
double  b
 

Returns the maximum of a and b.

SIM_API double min double  a,
double  b
 

Returns the minimum of a and b.

SIM_API char* opp_concat const char *  s1,
const char *  s2,
const char *  s3 = NULL,
const char *  s4 = NULL
 

Concatenates up to four strings.

Returns a pointer to a static buffer of length 256. If the result length would exceed 256, it is truncated.

SIM_API char* opp_mkindexedname char *  dest,
const char *  name,
int  index
 

Creates a string like "component[35]" into dest, the first argument.

SIM_API int opp_strcmp const char *  ,
const char * 
 

Same as the standard strcmp() function, except that NULL pointers are treated like pointers to a null string ("").

SIM_API char* opp_strcpy char *  ,
const char * 
 

Same as the standard strcpy() function, except that NULL pointers in the second argument are treated like pointers to a null string ("").

SIM_API char* opp_strdup const char *   ) 
 

Duplicates the string.

If the pointer passed is NULL or points to a null string (""), NULL is returned.

SIM_API int opp_strlen const char *   ) 
 

Same as the standard strlen() function, except that does not crash on NULL pointers but returns 0.

SIM_API bool opp_strmatch const char *  ,
const char * 
 

Returns true if the two strings are identical up to the length of the shorter one.

NULL pointers are treated like pointers to a null string ("").

SIM_API char* opp_strprettytrunc char *  dest,
const char *  src,
unsigned  maxlen
 

Copies src string into desc, 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 double shift_left double  a,
double  b
 

Shifts a b bits to the left.

(a and b are converted to unsigned long for the operation.)

SIM_API double shift_right double  a,
double  b
 

Shifts a b bits to the right.

(a and b are converted to unsigned long for the operation.)

SIM_API char* simtimeToStr simtime_t  t,
char *  dest = NULL
 

Converts simulation time (passed as simtime_t) into a string like "0.0120000 (12ms)".

If no destination pointer is given, it will use a static buffer.

SIM_API char* simtimeToStrShort simtime_t  t,
char *  buf = NULL
 

Converts simulation time (passed as simtime_t) into a short string form like "12.37ms".

If no destination pointer is given, it will use a static buffer.

SIM_API simtime_t strToSimtime const char *  str  ) 
 

Convert a string to simtime_t.

The string should have a format similar to the one output by simtimeToStr() (like "1s 34ms").

Returns -1 if the whole string cannot be interpreted as time. Empty string (or only spaces+tabs) is also an error. E.g. strtoSimtime("3s 600ms x") will return -1.

SIM_API simtime_t strToSimtime0 const char *&  str  ) 
 

Convert the beginning of a string to simtime_t.

Similar to strToSimtime(), only it processes the string as far as it can be interpreted as simulation time. It sets the pointer passed to the first character which cannot be interpreted as part of the time string, or to the terminating zero. Empty string is accepted as 0.0.

Example: strToSimtime0("3s 600ms x") will return 3.6 and the str pointer will point to the character 'x'.


Generated on Thu Jan 12 16:01:41 2006 for OMNeT++/OMNEST Simulation Library by  doxygen 1.4.1