replace typedef function ptr by std::function
start PIMap refactoring
This commit is contained in:
@@ -194,7 +194,7 @@ int PIEvaluatorContent::addVariable(const PIString & name, const complexd & val)
|
||||
}
|
||||
|
||||
|
||||
void PIEvaluatorContent::addCustomFunction(const PIString & name, int args_count, FuncFunc func) {
|
||||
void PIEvaluatorContent::addCustomFunction(const PIString & name, int args_count, PIEvaluatorTypes::FuncHanlder func) {
|
||||
functions << PIEvaluatorTypes::Function(name, args_count, func);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,10 +29,11 @@
|
||||
#include "pistringlist.h"
|
||||
#include "pimathcomplex.h"
|
||||
|
||||
typedef complexd (*FuncFunc)(void * , int, complexd * );
|
||||
|
||||
namespace PIEvaluatorTypes {
|
||||
|
||||
typedef std::function<complexd(void * , int, complexd * )> FuncHanlder;
|
||||
|
||||
enum eType {etNumber, etOperator, etVariable, etFunction};
|
||||
enum Operation {oNone, oAdd, oSubtract, oMultiply, oDivide, oResidue, oPower,
|
||||
oEqual, oNotEqual, oGreater, oSmaller, oGreaterEqual, oSmallerEqual,
|
||||
@@ -70,12 +71,12 @@ namespace PIEvaluatorTypes {
|
||||
short var_num;
|
||||
};
|
||||
struct PIP_EXPORT Function {
|
||||
Function() {arguments = 0; type = bfUnknown; handler = 0;}
|
||||
Function(const PIString & name, short args, BaseFunctions ftype) {identifier = name; arguments = args; type = ftype; handler = 0;}
|
||||
Function(const PIString & name, short args, FuncFunc h) {identifier = name; arguments = args; type = bfCustom; handler = h;}
|
||||
Function() {arguments = 0; type = bfUnknown; handler = nullptr;}
|
||||
Function(const PIString & name, short args, BaseFunctions ftype) {identifier = name; arguments = args; type = ftype; handler = nullptr;}
|
||||
Function(const PIString & name, short args, FuncHanlder h) {identifier = name; arguments = args; type = bfCustom; handler = h;}
|
||||
PIString identifier;
|
||||
BaseFunctions type;
|
||||
FuncFunc handler;
|
||||
FuncHanlder handler;
|
||||
short arguments;
|
||||
};
|
||||
struct PIP_EXPORT Variable {
|
||||
@@ -103,7 +104,7 @@ public:
|
||||
|
||||
void addFunction(const PIString & name, int args = 1);
|
||||
int addVariable(const PIString & name, const complexd & val = 0.);
|
||||
void addCustomFunction(const PIString & name, int args_count, FuncFunc func);
|
||||
void addCustomFunction(const PIString & name, int args_count, PIEvaluatorTypes::FuncHanlder func);
|
||||
int functionsCount() const {return functions.size();}
|
||||
int variablesCount() const {return variables.size();}
|
||||
int customVariablesCount() const;
|
||||
|
||||
Reference in New Issue
Block a user