OMNeT++ API 6.1
Discrete Event Simulation Library
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 
24 namespace omnetpp {
25 
26 
33 typedef double (*MathFunc)(...);
34 
41 typedef double (*MathFuncNoArg)();
42 
49 typedef double (*MathFunc1Arg)(double);
50 
57 typedef double (*MathFunc2Args)(double,double);
58 
65 typedef double (*MathFunc3Args)(double,double,double);
66 
73 typedef double (*MathFunc4Args)(double,double,double,double);
74 
75 
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:
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 
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 
133  virtual std::string str() const override;
135 
141  int getNumArgs() const {return argc;}
142 
147  MathFunc getMathFunc() const {return f;}
148 
153  MathFuncNoArg getMathFuncNoArg() const;
154 
159  MathFunc1Arg getMathFunc1Arg() const;
160 
165  MathFunc2Args getMathFunc2Args() const;
166 
171  MathFunc3Args getMathFunc3Args() const;
172 
177  MathFunc4Args getMathFunc4Args() const;
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 
204  static cNedMathFunction *findByPointer(MathFunc f);
205 
206 };
207 
208 // cNEDMathFunction was renamed cNedMathFunction in OMNeT++ 5.3; typedef added for compatibility
209 typedef cNedMathFunction cNEDMathFunction;
210 
211 } // namespace omnetpp
212 
213 
214 #endif
215 
216 
omnetpp::cNedMathFunction::~cNedMathFunction
virtual ~cNedMathFunction()
Definition: cnedmathfunction.h:125
omnetpp::MathFunc2Args
double(* MathFunc2Args)(double, double)
Prototype for mathematical functions taking two arguments.
Definition: cnedmathfunction.h:57
omnetpp::cNedMathFunction::getMathFunc
MathFunc getMathFunc() const
Definition: cnedmathfunction.h:147
omnetpp::MathFunc3Args
double(* MathFunc3Args)(double, double, double)
Prototype for mathematical functions taking three arguments.
Definition: cnedmathfunction.h:65
omnetpp::MathFunc
double(* MathFunc)(...)
Prototype for mathematical functions.
Definition: cnedmathfunction.h:33
omnetpp::cNedMathFunction::getNumArgs
int getNumArgs() const
Definition: cnedmathfunction.h:141
omnetpp::MathFunc4Args
double(* MathFunc4Args)(double, double, double, double)
Prototype for mathematical functions taking four arguments.
Definition: cnedmathfunction.h:73
omnetpp::MathFunc1Arg
double(* MathFunc1Arg)(double)
Prototype for mathematical functions taking one argument.
Definition: cnedmathfunction.h:49
omnetpp::cNedMathFunction
Registration class for extending NED with new mathematical functions.
Definition: cnedmathfunction.h:85
omnetpp::MathFuncNoArg
double(* MathFuncNoArg)()
Prototype for mathematical functions taking no arguments.
Definition: cnedmathfunction.h:41
omnetpp::cNoncopyableOwnedObject
Base class for cOwnedObject-based classes that do not wish to support assignment and duplication.
Definition: cownedobject.h:242
omnetpp::cNedMathFunction::getCategory
const char * getCategory() const
Definition: cnedmathfunction.h:183
omnetpp::cNedMathFunction::getDescription
const char * getDescription() const
Definition: cnedmathfunction.h:188