CXXR (C++ R) API
|
Monitor function application for binary functions. More...
#include <BinaryFunction.hpp>
Public Member Functions | |
BinaryNAPropagator (const Functor &f) | |
Constructor. | |
result_type | operator() (const first_argument_type &left, const second_argument_type &right) const |
Monitored invocation of f . | |
void | warnings () |
Raise warnings after processing a vector. |
Monitor function application for binary functions.
VectorOps::BinaryFunction takes as a template parameter a FunctorWrapper class template. The apply() method of BinaryFunction creates an object from this template, and delegates to it the task of calling the binary function; the FunctorWrapper object can then monitor any special conditions that occur, and take appropriate action either immediately (for example by raising an error and/or modifying the result value) or when processing of the input vector is complete (typically by providing one or more warnings).
This template is the default value of the FunctorWrapper template parameter, and its effect is to ensure that if either of the arguments to the binary function is NA, then the result is set to NA (without actually calling the binary function). If different behaviour is required, another class can be created using this class as a model.
first_argument_type | Element type of the first operand to the BinaryFunction. |
second_argument_type | Element type of the second operand to the BinaryFunction. |
result_type | Element type of the result of the BinaryFunction. |
Functor | Function or function object type, representing a binary function. ElementTraits<first_argument_type>::Data::Type must be convertible to the type of the first argument of this function, and likewise ElementTraits<second_argument_type>::Data::Type must be convertible to the type of the second argument of this function. The result of the function must be assignable to result_type . |
|
inline |
Constructor.
f | Pointer to an object of type Functor defining the binary function whose operation this FunctorWrapper is to monitor. |
|
inline |
Monitored invocation of f .
The apply() method of an object instantiating the VectorOps::BinaryFunction template will call this function to generate a value for an element of the output vector from the values of the corresponding elements of the operands, using the functor f .
left | First argument to which f is to be applied. |
right | Second argument to which f is to be applied. |
|
inline |
Raise warnings after processing a vector.
The apply() method of an object instantiating the VectorOps::BinaryFunction template will call this function once all the elements of the input vector have been processed. Typically this function will do nothing if no abnormalities have occurred during the lifetime of this FunctorWrapper object , otherwise it will raise one or more warnings. (Note that the lifetime of a FunctorWrapper object corresponds to the processing of an input vector by the apply() method of BinaryFunction.)
The default behaviour, implemented here, is to do nothing.