Embedded Multicore Building Blocks V1.0.0
Public Member Functions | List of all members
embb::base::Function< ReturnType,... > Class Template Reference

Wraps function pointers, member function pointers, and functors with up to five arguments. More...

#include <function.h>

Public Member Functions

template<class ClassType >
 Function (ClassType const &obj)
 Constructor from functor. More...
 
 Function (ReturnType(*func)(...))
 Constructor from function pointer with return type ReturnType and up to five arguments. More...
 
template<class ClassType >
 Function (ClassType &obj, ReturnType(ClassType::*func)(...))
 Constructor from object and member function pointer with return type ReturnType and up to five arguments. More...
 
 Function (Function const &func)
 Copy constructor. More...
 
 ~Function ()
 Destructor. More...
 
void operator= (ReturnType(*func)(...))
 Assigns this object a new function pointer. More...
 
void operator= (Function &func)
 Assigns this object another Function. More...
 
template<class C >
void operator= (C const &obj)
 Assigns this object a new functor. More...
 
ReturnType operator() (...)
 Calls the wrapped function with the given parameters. More...
 

Detailed Description

template<typename ReturnType, ...>
class embb::base::Function< ReturnType,... >

Wraps function pointers, member function pointers, and functors with up to five arguments.

Constructor & Destructor Documentation

template<typename ReturnType, ... >
template<class ClassType >
embb::base::Function< ReturnType,... >::Function ( ClassType const &  obj)
explicit

Constructor from functor.

Uses operator() with return type ReturnType and up to five arguments. Copies the functor.

Dynamic memory allocation
Allocates memory for the copy of the functor.
Parameters
objThe functor to wrap.
template<typename ReturnType, ... >
embb::base::Function< ReturnType,... >::Function ( ReturnType(*)(...)  func)
explicit

Constructor from function pointer with return type ReturnType and up to five arguments.

Parameters
funcThe function pointer.
template<typename ReturnType, ... >
template<class ClassType >
embb::base::Function< ReturnType,... >::Function ( ClassType &  obj,
ReturnType(ClassType::*)(...)  func 
)

Constructor from object and member function pointer with return type ReturnType and up to five arguments.

Parameters
objReference to object.
funcMember function pointer.
template<typename ReturnType, ... >
embb::base::Function< ReturnType,... >::Function ( Function< ReturnType,... > const &  func)

Copy constructor.

Parameters
funcThe Function to copy.
template<typename ReturnType, ... >
embb::base::Function< ReturnType,... >::~Function ( )

Destructor.

Member Function Documentation

template<typename ReturnType, ... >
void embb::base::Function< ReturnType,... >::operator= ( ReturnType(*)(...)  func)

Assigns this object a new function pointer.

Parameters
funcThe function pointer.
template<typename ReturnType, ... >
void embb::base::Function< ReturnType,... >::operator= ( Function< ReturnType,... > &  func)

Assigns this object another Function.

Parameters
funcThe Function.
template<typename ReturnType, ... >
template<class C >
void embb::base::Function< ReturnType,... >::operator= ( C const &  obj)

Assigns this object a new functor.

The functor is copied.

Parameters
objThe functor.
template<typename ReturnType, ... >
ReturnType embb::base::Function< ReturnType,... >::operator() (   ...)

Calls the wrapped function with the given parameters.

Returns
A value generated by the wrapped function.