ECF 1.5
|
Public Member Functions | |
void | evaluate (Container &container, Result &result) |
Public Member Functions inherited from cartesian::Function< Container, Result > | |
Function (uint numArgs) | |
virtual void | evaluate (Container &container, Result &result)=0 |
std::string | getName () |
uint | getNumOfArgs () |
Additional Inherited Members | |
Protected Attributes inherited from cartesian::Function< Container, Result > | |
std::string | name_ |
uint | numOfArgs_ |
cartesian::Max< Container, Result >::Max |
|
inline |
|
virtual |
Evaluate function could be done in a better way. What it does is it takes inputs to a function node as first argument and result as a second argument.
Problem arises because of the following: 1.) Passed input should support an operation which is performed(+, -, *, /, sqrt, max, min). This is not a problem for built-in types, but does create a problem for user-defined types or aggregate-types.
2.) Assuming that input is given as a collection or any stl container, strictly speaking all support needed for first argument is to be able to iterate over it.
For general usage, abstract function evaluate could be defined as: virtual void evaluate(voidP inputs, void* result) = 0;
However this would require that concrete functions (derived classes of Function) know in what to cast voidP and void*. This could be achieved using class templates. Still, user would have to know in what to cast inputs.
I opted for a solution of making base-class a template class, and arguments of evaluate function container and a result.
Solution I like the most (once C++ 2020 is supported by compilers) is to use concepts, and scrape inheritance completely.
Implements cartesian::Function< Container, Result >.