cnedmathfunction.h Source File

API: cnedmathfunction.h Source File
API
cnedmathfunction.h
1//==========================================================================
2// CMATHFUNCTION.H - part of
3// OMNeT++/OMNEST
4// Discrete System Simulation in C++
5//
6//==========================================================================
7
8/*--------------------------------------------------------------*
9 Copyright (C) 1992-2017 Andras Varga
10 Copyright (C) 2006-2017 OpenSim Ltd.
11
12 This file is distributed WITHOUT ANY WARRANTY. See the file
13 `license' for details on this and other legal matters.
14*--------------------------------------------------------------*/
15
16#ifndef __OMNETPP_CMATHFUNCTION_H
17#define __OMNETPP_CMATHFUNCTION_H
18
19#include <cstdarg>
20#include "simkerneldefs.h"
21#include "globals.h"
22#include "cownedobject.h"
23
24namespace omnetpp {
25
26
33typedef double (*MathFunc)(...);
34
41typedef double (*MathFuncNoArg)();
42
49typedef double (*MathFunc1Arg)(double);
50
57typedef double (*MathFunc2Args)(double,double);
58
65typedef double (*MathFunc3Args)(double,double,double);
66
73typedef double (*MathFunc4Args)(double,double,double,double);
74
75
85class SIM_API cNedMathFunction : public cNoncopyableOwnedObject
86{
87 private:
88 MathFunc f; // pointer to the function
89 int argc; // argument count (up to 4 doubles)
90 std::string category; // category string; only used when listing all functions
91 std::string description; // optional documentation string
92
93 public:
96
99 cNedMathFunction(const char *name, MathFuncNoArg f, int argc=-1, const char *category=nullptr, const char *description=nullptr);
100
104 cNedMathFunction(const char *name, MathFunc1Arg f, int argc=-1, const char *category=nullptr, const char *description=nullptr);
105
109
110 cNedMathFunction(const char *name, MathFunc2Args f, int argc=-1, const char *category=nullptr, const char *description=nullptr);
111
115 cNedMathFunction(const char *name, MathFunc3Args f, int argc=-1, const char *category=nullptr, const char *description=nullptr);
116
120 cNedMathFunction(const char *name, MathFunc4Args f, int argc=-1, const char *category=nullptr, const char *description=nullptr);
121
125 virtual ~cNedMathFunction() {}
127
130
133 virtual std::string str() const override;
135
138
141 int getNumArgs() const {return argc;}
142
147 MathFunc getMathFunc() const {return f;}
148
154
160
166
172
178
183 const char *getCategory() const {return category.c_str();}
184
188 const char *getDescription() const {return description.c_str();}
190
194 static cNedMathFunction *find(const char *name, int numArgs);
195
199 static cNedMathFunction *get(const char *name, int numArgs);
200
205
206};
207
208// cNEDMathFunction was renamed cNedMathFunction in OMNeT++ 5.3; typedef added for compatibility
209typedef cNedMathFunction cNEDMathFunction;
210
211} // namespace omnetpp
212
213
214#endif
215
216
Registration class for extending NED with new mathematical functions.
Definition cnedmathfunction.h:86
cNedMathFunction(const char *name, MathFunc4Args f, int argc=-1, const char *category=nullptr, const char *description=nullptr)
static cNedMathFunction * find(const char *name, int numArgs)
MathFunc2Args getMathFunc2Args() const
MathFunc3Args getMathFunc3Args() const
static cNedMathFunction * findByPointer(MathFunc f)
const char * getCategory() const
Definition cnedmathfunction.h:183
static cNedMathFunction * get(const char *name, int numArgs)
int getNumArgs() const
Definition cnedmathfunction.h:141
MathFunc4Args getMathFunc4Args() const
cNedMathFunction(const char *name, MathFunc2Args f, int argc=-1, const char *category=nullptr, const char *description=nullptr)
cNedMathFunction(const char *name, MathFunc3Args f, int argc=-1, const char *category=nullptr, const char *description=nullptr)
cNedMathFunction(const char *name, MathFuncNoArg f, int argc=-1, const char *category=nullptr, const char *description=nullptr)
const char * getDescription() const
Definition cnedmathfunction.h:188
virtual ~cNedMathFunction()
Definition cnedmathfunction.h:125
virtual std::string str() const override
MathFuncNoArg getMathFuncNoArg() const
cNedMathFunction(const char *name, MathFunc1Arg f, int argc=-1, const char *category=nullptr, const char *description=nullptr)
MathFunc getMathFunc() const
Definition cnedmathfunction.h:147
MathFunc1Arg getMathFunc1Arg() const
double(* MathFunc4Args)(double, double, double, double)
Prototype for mathematical functions taking four arguments.
Definition cnedmathfunction.h:73
double(* MathFunc2Args)(double, double)
Prototype for mathematical functions taking two arguments.
Definition cnedmathfunction.h:57
double(* MathFunc1Arg)(double)
Prototype for mathematical functions taking one argument.
Definition cnedmathfunction.h:49
double(* MathFunc)(...)
Prototype for mathematical functions.
Definition cnedmathfunction.h:33
double(* MathFunc3Args)(double, double, double)
Prototype for mathematical functions taking three arguments.
Definition cnedmathfunction.h:65
double(* MathFuncNoArg)()
Prototype for mathematical functions taking no arguments.
Definition cnedmathfunction.h:41