#include <cnedfunction.h>
Registration class for extending NED with arbitrary new functions.
Objects of this class are usually created via the Define_NED_Function() macro.
◆ cNedFunction()
cNedFunction |
( |
NedFunction |
f, |
|
|
const char * |
signature, |
|
|
const char * |
category = nullptr , |
|
|
const char * |
description = nullptr |
|
) |
| |
Constructor. Signature is expected in the following syntax: returntype name(argtype argname,...), where types can be bool, long, double, quantity, intquantity, string, xml, any; names of optional arguments end in '?'. The object name will be the function name, as extracted from the signature string. The signature may end in an ellipsis, i.e. "...", to mean that any number of extra args of unspecified types should be accepted. (When there are both optional args and an ellipsis, then extra arguments can only be passed when all optional arguments are all supplied.)
Examples: "quantity uniform(quantity a, quantity b, long rng?)" "string sprintf(format, ...)" "any max(...)"
◆ ~cNedFunction()
◆ str()
virtual std::string str |
( |
| ) |
const |
|
overridevirtual |
Produces a one-line description of the object's contents.
Reimplemented from cObject.
◆ invoke()
Performs argument type checking, and invokes the function.
◆ getFunctionPointer()
NedFunction getFunctionPointer |
( |
| ) |
const |
|
inline |
Returns the function pointer. Do not call the function directly, because that would bypass argument type validation.
◆ getSignature()
const char* getSignature |
( |
| ) |
const |
|
inline |
Returns the functions signature, as passed to the constructor
◆ getReturnType()
char getReturnType |
( |
| ) |
const |
|
inline |
Returns the function return type, one of the characters B,L,D,Q,S,X,* for bool, long, double, quantity, string, xml and any, respectively.
◆ getArgType()
char getArgType |
( |
int |
k | ) |
const |
|
inline |
Returns the type of the kth argument; result is one of the characters B,L,D,Q,S,X,* for bool, long, double, quantity, string, xml and any, respectively.
◆ getMinArgs()
Returns the minimum number of arguments (i.e. the number of mandatory arguments).
◆ getMaxArgs()
Returns the maximum number of typed arguments (i.e. the last max-min args are optional). If hasVarArgs() is true, the function actually accepts more than getMaxArgs() arguments.
◆ hasVarArgs()
bool hasVarArgs |
( |
| ) |
const |
|
inline |
Returns true if the function signature ends in an ellipsis ("..."), that is, the function supports varargs.
◆ getCategory()
const char* getCategory |
( |
| ) |
const |
|
inline |
Returns a string that can be useful in classifying NED functions, e.g. "trigonometric".
◆ getDescription()
const char* getDescription |
( |
| ) |
const |
|
inline |
Returns the function's documentation as a string.
◆ find()
Finds a registered function by name. Returns nullptr if not found.
◆ get()
Finds a registered function by name. Throws an error if not found.
◆ findByPointer()
Finds a registered function by function pointer.
The documentation for this class was generated from the following file: