replace typedef function ptr by std::function

start PIMap refactoring
This commit is contained in:
Бычков Андрей
2022-07-29 15:49:36 +03:00
parent 38fd1b5dc4
commit 4725eb96d6
9 changed files with 65 additions and 87 deletions

View File

@@ -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);
}

View File

@@ -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;