cnedmathfunction.h

00001 //==========================================================================
00002 //  CMATHFUNCTION.H - part of
00003 //                     OMNeT++/OMNEST
00004 //            Discrete System Simulation in C++
00005 //
00006 //==========================================================================
00007 
00008 /*--------------------------------------------------------------*
00009   Copyright (C) 1992-2008 Andras Varga
00010   Copyright (C) 2006-2008 OpenSim Ltd.
00011 
00012   This file is distributed WITHOUT ANY WARRANTY. See the file
00013   `license' for details on this and other legal matters.
00014 *--------------------------------------------------------------*/
00015 
00016 #ifndef __CMATHFUNCTION_H
00017 #define __CMATHFUNCTION_H
00018 
00019 #include <stdarg.h>
00020 #include "simkerneldefs.h"
00021 #include "globals.h"
00022 #include "cownedobject.h"
00023 
00024 NAMESPACE_BEGIN
00025 
00026 
00033 typedef double (*MathFunc)(...);
00034 
00041 typedef double (*MathFuncNoArg)();
00042 
00049 typedef double (*MathFunc1Arg)(double);
00050 
00057 typedef double (*MathFunc2Args)(double,double);
00058 
00065 typedef double (*MathFunc3Args)(double,double,double);
00066 
00073 typedef double (*MathFunc4Args)(double,double,double,double);
00074 
00075 
00084 class SIM_API cNEDMathFunction : public cNoncopyableOwnedObject
00085 {
00086   private:
00087     MathFunc f;            // pointer to the function
00088     int argc;              // argument count (up to 4 doubles)
00089     std::string categ;     // category string; only used when listing all functions
00090     std::string desc;      // optional documentation string
00091 
00092   public:
00098     cNEDMathFunction(const char *name, MathFuncNoArg f, int argc=-1, const char *category=NULL, const char *description=NULL);
00099 
00103     cNEDMathFunction(const char *name, MathFunc1Arg f, int argc=-1, const char *category=NULL, const char *description=NULL);
00104 
00109     cNEDMathFunction(const char *name, MathFunc2Args f, int argc=-1, const char *category=NULL, const char *description=NULL);
00110 
00114     cNEDMathFunction(const char *name, MathFunc3Args f, int argc=-1, const char *category=NULL, const char *description=NULL);
00115 
00119     cNEDMathFunction(const char *name, MathFunc4Args f, int argc=-1, const char *category=NULL, const char *description=NULL);
00120 
00124     virtual ~cNEDMathFunction() {}
00126 
00132     virtual std::string info() const;
00134 
00140     int getNumArgs() const  {return argc;}
00141 
00146     MathFunc getMathFunc() const {return f;}
00147 
00152     MathFuncNoArg getMathFuncNoArg() const;
00153 
00158     MathFunc1Arg getMathFunc1Arg() const;
00159 
00164     MathFunc2Args getMathFunc2Args() const;
00165 
00170     MathFunc3Args getMathFunc3Args() const;
00171 
00176     MathFunc4Args getMathFunc4Args() const;
00177 
00182     const char *getCategory() const  {return categ.c_str();}
00183 
00187     const char *getDescription() const  {return desc.c_str();}
00189 
00193     static cNEDMathFunction *find(const char *name, int numArgs);
00194 
00198     static cNEDMathFunction *get(const char *name, int numArgs);
00199 
00203     static cNEDMathFunction *findByPointer(MathFunc f);
00204 
00205 };
00206 
00207 NAMESPACE_END
00208 
00209 
00210 #endif
00211 
00212 
Generated on Tue Dec 2 11:16:27 2014 for OMNeT++ Simulation Library by  doxygen 1.6.3