OpenCurves
0.9
|
A PlotFunctionRegister
stores function implementations to expose to the plot expression generator.
More...
#include <plotfunctionregister.h>
Public Member Functions | |
PlotFunctionRegister (bool registerDefaults=true) | |
Constructor - optinally register default/built-in functions. More... | |
~PlotFunctionRegister () | |
Destructor. Destroys all functions which the register owns. | |
FunctionSimple * | add (FunctionSimple::ValueFunctionPtr function, const QString &category, const QString &name, const QString &description) |
Add a function to the register using a FunctionSimple object with a FunctionSimple::ValueFunction implementation. More... | |
FunctionSimple * | add (FunctionSimple::ExpandedFunctionPtr function, const QString &category, const QString &name, const QString &description, unsigned argc=0, bool variadic=false) |
Add a function to the register using a FunctionSimple object with a FunctionSimple::ExpandedFunction implementation. More... | |
FunctionDefinition * | add (FunctionDefinition *functionDef, bool takeOwnership=true) |
A a function by object. More... | |
const FunctionDefinition * | find (const QString &name) const |
Search for a function by name : exact match with FunctionDefinition::name() . More... | |
void | registerDefaultFunctions () |
Register built in functions. May have already been called from the constructor. | |
const QVector< FunctionDefinition * > & | definitions () const |
Fetch all registered functions. More... | |
const QStringList | categories () const |
Return the list of category names which covers all registered functions. More... | |
unsigned | getDefinitionsInCategory (const QString &categoryName, QVector< const FunctionDefinition * > &definitions) const |
Request definitions in a particular category. More... | |
Protected Member Functions | |
void | ensureCategoryIsPresent (const QString &categoryName) |
Ensure that categoryName is present in the list of categories. More... | |
A PlotFunctionRegister
stores function implementations to expose to the plot expression generator.
These functions represent arbitrary operations which can be performed in a plot expression. Function implementations are free to perform whatever calculations they wish (within reason) based on the given inputs. For example, the max() function tracks the running maximum of the input expression.
Function implementations are added by calling add()
.
PlotFunctionRegister::PlotFunctionRegister | ( | bool | registerDefaults = true | ) |
Constructor - optinally register default/built-in functions.
Built-in functions can be registered later by calling registerDefaultFunctions()
.
registerDefaults | True to register the default/build-in functions. |
FunctionSimple* PlotFunctionRegister::add | ( | FunctionSimple::ValueFunctionPtr | function, |
const QString & | category, | ||
const QString & | name, | ||
const QString & | description | ||
) |
Add a function to the register using a FunctionSimple
object with a FunctionSimple::ValueFunction
implementation.
function | The function pointer handling calculation of the results. |
category | The category for the function, used for grouping in the UI. |
name | The function name. Used as the function identifier. Follows identifier rules for valid characters. |
description | Description shown to the user. Cannot be translated yet. |
FunctionSimple
object instantiated to invoke function
, or null on failure. FunctionSimple* PlotFunctionRegister::add | ( | FunctionSimple::ExpandedFunctionPtr | function, |
const QString & | category, | ||
const QString & | name, | ||
const QString & | description, | ||
unsigned | argc = 0 , |
||
bool | variadic = false |
||
) |
Add a function to the register using a FunctionSimple
object with a FunctionSimple::ExpandedFunction
implementation.
function | The function pointer handling calculation of the results. |
category | The category for the function, used for grouping in the UI. |
name | The function name. Used as the function identifier. Follows identifier rules for valid characters. |
argc | The minimum number of arguments the function requires. |
description | Description shown to the user. Cannot be translated yet. |
variadic | Set to true if the function is variadic and supports a variable number of parameters after argc . |
FunctionSimple
object instantiated to invoke function
, or null on failure. FunctionDefinition* PlotFunctionRegister::add | ( | FunctionDefinition * | functionDef, |
bool | takeOwnership = true |
||
) |
A a function by object.
functionDef | The function definition. This class takes ownership of the pointer if takeOwnership is true. |
takeOwnership | True if this class will delete functionDef (call delete). |
FunctionDefinition
object functionDef
on success or null on failure.
|
inline |
Return the list of category names which covers all registered functions.
|
inline |
Fetch all registered functions.
|
protected |
Ensure that categoryName
is present in the list of categories.
categoryName | The category name to ensure is present. |
const FunctionDefinition* PlotFunctionRegister::find | ( | const QString & | name | ) | const |
Search for a function by name : exact match with FunctionDefinition::name()
.
name | The name to match. |
unsigned PlotFunctionRegister::getDefinitionsInCategory | ( | const QString & | categoryName, |
QVector< const FunctionDefinition * > & | definitions | ||
) | const |
Request definitions in a particular category.
categoryName | The category to match (exact match). |
definitions | Matching definitions are added to this container. |
definitions
.