CXXR (C++ R)
Public Member Functions
CXXR::VectorOps::UnaryNAPropagator< argument_type, result_type, Functor > Class Template Reference

Monitor function application for unary functions. More...

#include <UnaryFunction.hpp>

List of all members.

Public Member Functions

 UnaryNAPropagator (const Functor &f)
 Constructor.
result_type operator() (const argument_type &in) const
 Monitored invocation of f .
void warnings ()
 Raise warnings after processing a vector.

Detailed Description

template<typename argument_type, typename result_type, typename Functor>
class CXXR::VectorOps::UnaryNAPropagator< argument_type, result_type, Functor >

Monitor function application for unary functions.

VectorOps::UnaryFunction takes as a template parameter a FunctorWrapper class template. The apply() method of UnaryFunction creates an object from this template, and delegates to it the task of calling the unary 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 the argument to the unary function is NA, then the result is set to NA (without actually calling the unary function). If different behaviour is required, another class can be created using this class as a model.

Template Parameters:
argument_typeElement type of the input vector of the UnaryFunction.
result_typeElement type of the result of the UnaryFunction.
FunctorFunction or function object type, representing a unary function. ElementTraits<argument_type>::Data::Type must be convertible to the type of the argument of this function. The result of the function must be assignable to result_type .

Constructor & Destructor Documentation

template<typename argument_type , typename result_type , typename Functor >
CXXR::VectorOps::UnaryNAPropagator< argument_type, result_type, Functor >::UnaryNAPropagator ( const Functor &  f)
inline

Constructor.

Parameters:
fPointer to an object of type Functor defining the unary function whose operation this FunctorWrapper is to monitor.

Member Function Documentation

template<typename argument_type , typename result_type , typename Functor >
result_type CXXR::VectorOps::UnaryNAPropagator< argument_type, result_type, Functor >::operator() ( const argument_type &  in) const
inline

Monitored invocation of f .

The apply() method of an object instantiating the VectorOps::UnaryFunction template will call this function to generate a value for an element of the output vector from the value of the corresponding element of the input vector, using the functor f .

Parameters:
inElement of the input vector to which f is to be applied.
Returns:
If in is NA, then ElementTraits<result_type>::NA(), and in this case f is not actually called. Otherwise, the result of applying f to the element data of in .
template<typename argument_type , typename result_type , typename Functor >
void CXXR::VectorOps::UnaryNAPropagator< argument_type, result_type, Functor >::warnings ( )
inline

Raise warnings after processing a vector.

The apply() method of an object instantiating the VectorOps::UnaryFunction 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 UnaryFunction.)

The default behaviour, implemented here, is to do nothing.


The documentation for this class was generated from the following file: