#include <cnedfunction.h>

Objects of this class are usually created via the Define_NED_Function() macro.
Public Member Functions | |
Constructors, destructor, assignment | |
| cNEDFunction (NEDFunction f, const char *signature, const char *category=NULL, const char *description=NULL) | |
| virtual | ~cNEDFunction () |
Redefined cObject member functions. | |
| virtual std::string | info () const |
Member access. | |
| cNEDValue | invoke (cComponent *context, cNEDValue argv[], int argc) |
| NEDFunction | getFunctionPointer () const |
| const char * | getSignature () const |
| char | getReturnType () const |
| char | getArgType (int k) const |
| int | getMinArgs () const |
| int | getMaxArgs () const |
| bool | hasVarArgs () const |
| const char * | getCategory () const |
| const char * | getDescription () const |
Static Public Member Functions | |
| static cNEDFunction * | find (const char *name) |
| static cNEDFunction * | get (const char *name) |
| static cNEDFunction * | findByPointer (NEDFunction f) |
| cNEDFunction::cNEDFunction | ( | NEDFunction | f, | |
| const char * | signature, | |||
| const char * | category = NULL, |
|||
| const char * | description = NULL | |||
| ) |
Constructor.
Signature is expected in the following syntax: returntype name(argtype argname,...), where types can be bool, long, double, quantity, 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(...)"
| virtual cNEDFunction::~cNEDFunction | ( | ) | [inline, virtual] |
Destructor.
| virtual std::string cNEDFunction::info | ( | ) | const [virtual] |
| cNEDValue cNEDFunction::invoke | ( | cComponent * | context, | |
| cNEDValue | argv[], | |||
| int | argc | |||
| ) |
Performs argument type checking, and invokes the function.
| NEDFunction cNEDFunction::getFunctionPointer | ( | ) | const [inline] |
Returns the function pointer.
Do not call the function directly, because that would bypass argument type validation.
| const char* cNEDFunction::getSignature | ( | ) | const [inline] |
Returns the functions signature, as passed to the constructor.
| char cNEDFunction::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.
| char cNEDFunction::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.
| int cNEDFunction::getMinArgs | ( | ) | const [inline] |
Returns the minimum number of arguments (i.e.
the number of mandatory arguments).
| int cNEDFunction::getMaxArgs | ( | ) | const [inline] |
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.
| bool cNEDFunction::hasVarArgs | ( | ) | const [inline] |
Returns true if the function signature ends in an ellipsis ("..."), that is, the function supports varargs.
| const char* cNEDFunction::getCategory | ( | ) | const [inline] |
Returns a string that can be useful in classifying NED functions, e.g.
"trigonometric".
| const char* cNEDFunction::getDescription | ( | ) | const [inline] |
Returns the function's documentation as a string.
| static cNEDFunction* cNEDFunction::find | ( | const char * | name | ) | [static] |
Finds a registered function by name.
Returns NULL if not found.
| static cNEDFunction* cNEDFunction::get | ( | const char * | name | ) | [static] |
Finds a registered function by name.
Throws an error if not found.
| static cNEDFunction* cNEDFunction::findByPointer | ( | NEDFunction | f | ) | [static] |
Finds a registered function by function pointer.
1.5.5