functor< T > Class Template Reference

Functor class for interfacing algorithms. More...

List of all members.

Public Member Functions

 functor ()
 Default constructor.
template<typename F >
 functor (F f)
 Copy constructor.
void init (const properties::ptr &settings, const properties::ptr &statistics)
 Initializes the settings and statistics fields.
const revkit::properties::ptrsettings () const
 Returns a smart pointer to the settings.
const revkit::properties::ptrstatistics () const
 Returns a smart pointer to the statistics.

Detailed Description

template<typename T>
class revkit::functor< T >

Functor class for interfacing algorithms.

When interfacing an algorithm, we wanna encapsulate the settings and the statistics. That is, a user can still provide settings from outside, but another algorithm can change settings of a functor as well. Therewith, this class extends the boost::function object by adding methods to access the corresponding settings and statistics data from the respective algorithm.

Author:
RevKit
Since:
1.0

Constructor & Destructor Documentation

functor (  )  [inline]

Default constructor.

Calls the constructor of the base class.

Author:
RevKit
Since:
1.0
functor ( f  )  [inline]

Copy constructor.

This copy constructor allows for example, the assignment of other boost::function objects or even boost::bind or boost::lambda expressions. Note, that the settings and statistics are not set with this constructor, but have to be assigned explicitly using init().

Parameters:
f Object to be assigned
Author:
RevKit
Since:
1.0

Member Function Documentation

void init ( const properties::ptr settings,
const properties::ptr statistics 
) [inline]

Initializes the settings and statistics fields.

This method is usually called by the functor creation function to assign the settings and statistics data, e.g. in swop_func:

 typedef functor<bool(circuit&, const binary_truth_table&)> truth_table_synthesis_func;

 ...

 truth_table_synthesis_func swop_func( properties::ptr settings, properties::ptr statistics )
 {
   truth_table_synthesis_func f = boost::bind( swop, _1, settings, statistics );
   f.init( settings, statistics );
   return f;
 }

In this example, the settings and statistics objects are given as parameters to the swop function in the boost::bind expression, so that they are available when calling the algorithm. Further they are passed to the functor explicitly via init() to make them available using the functor, e.g. in other algorithms.

Parameters:
settings Settings properties
statistics Statistics properties
Author:
RevKit
Since:
1.0
const revkit::properties::ptr& settings (  )  const [inline]

Returns a smart pointer to the settings.

This smart pointer can be empty, if init() was never called.

Returns:
A smart pointer to the settings
const revkit::properties::ptr& statistics (  )  const [inline]

Returns a smart pointer to the statistics.

This smart pointer can be empty, if init() was never called.

Returns:
A smart pointer to the statistics

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

Generated on Tue Dec 21 2010 21:52:13 for RevKit by doxygen 1.7.1