All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
roboptim::callback::Multiplexer< S > Class Template Reference

Callback multiplexer. More...

#include <roboptim/core/callback/multiplexer.hh>

Inheritance diagram for roboptim::callback::Multiplexer< S >:
roboptim::SolverCallback< S >

Public Types

typedef SolverCallback< S > parent_t
 Parent type. More...
 
typedef S solver_t
 Type of the solver. More...
 
typedef solver_t::problem_t problem_t
 Type of the problem. More...
 
typedef SolverState< problem_tsolverState_t
 Type of the state of the solver. More...
 
typedef SolverCallback< S > solverCallback_t
 Solver callback type. More...
 
typedef boost::shared_ptr
< solverCallback_t
solverCallbackPtr_t
 Pointer to a callback. More...
 
typedef std::vector
< solverCallbackPtr_t
solverCallbacks_t
 Type of a vector of callbacks. More...
 
- Public Types inherited from roboptim::SolverCallback< S >
typedef S solver_t
 Solver type. More...
 
typedef solver_t::problem_t problem_t
 Solver problem type. More...
 
typedef solver_t::callback_t callback_t
 Per-iteration callback type. More...
 
typedef solver_t::solverState_t solverState_t
 State of the solver. More...
 

Public Member Functions

 Multiplexer (solver_t &solver)
 Default constructor containing no callback. More...
 
 Multiplexer (solver_t &solver, const solverCallbacks_t &callbacks)
 Constructor filling the vector of callbacks. More...
 
virtual ~Multiplexer ()
 Virtual destructor. More...
 
solverCallbacks_tcallbacks ()
 Return the vector of callbacks. More...
 
const solverCallbacks_tcallbacks () const
 Return the vector of callbacks. More...
 
virtual std::ostream & print (std::ostream &o) const
 Display the callback on the specified output stream. More...
 
- Public Member Functions inherited from roboptim::SolverCallback< S >
 SolverCallback (const std::string &name="unnamed callback")
 Solver callback constructor. More...
 
virtual ~SolverCallback ()
 Destructor. More...
 
const std::string & name () const
 Return the name of the callback. More...
 
callback_t callback ()
 Callback function. More...
 
void operator() (const problem_t &pb, solverState_t &state)
 Evaluate the callback. More...
 

Protected Member Functions

virtual void perIterationCallbackUnsafe (const problem_t &pb, solverState_t &state)
 Meta-callback calling multiple callbacks. More...
 
void attach ()
 Register the multiplexer with the solver. More...
 
void unregister ()
 Unregister the multiplexer from the solver. More...
 
- Protected Member Functions inherited from roboptim::SolverCallback< S >
virtual void perIterationCallback (const problem_t &pb, solverState_t &state)
 Wrapper around the callback function that catch exceptions. More...
 
virtual void perIterationCallbackUnsafe (const problem_t &pb, solverState_t &state)=0
 The actual callback function. More...
 

Detailed Description

template<typename S>
class roboptim::callback::Multiplexer< S >

Callback multiplexer.

This class turns multiple callback functions into one. Note that callbacks are processed in the order of the vector of functions provided. Beware of conflicts between multiple callbacks.

Template Parameters
Ssolver type.

Member Typedef Documentation

template<typename S >
typedef SolverCallback<S> roboptim::callback::Multiplexer< S >::parent_t

Parent type.

template<typename S >
typedef solver_t::problem_t roboptim::callback::Multiplexer< S >::problem_t

Type of the problem.

template<typename S >
typedef S roboptim::callback::Multiplexer< S >::solver_t

Type of the solver.

template<typename S >
typedef SolverCallback<S> roboptim::callback::Multiplexer< S >::solverCallback_t

Solver callback type.

template<typename S >
typedef boost::shared_ptr<solverCallback_t> roboptim::callback::Multiplexer< S >::solverCallbackPtr_t

Pointer to a callback.

template<typename S >
typedef std::vector<solverCallbackPtr_t> roboptim::callback::Multiplexer< S >::solverCallbacks_t

Type of a vector of callbacks.

Type of the state of the solver.

Constructor & Destructor Documentation

template<typename S >
roboptim::callback::Multiplexer< S >::Multiplexer ( solver_t solver)
explicit

Default constructor containing no callback.

Parameters
solversolver the multiplexer will attach to.

References roboptim::callback::Multiplexer< S >::attach().

template<typename S >
roboptim::callback::Multiplexer< S >::Multiplexer ( solver_t solver,
const solverCallbacks_t callbacks 
)
explicit

Constructor filling the vector of callbacks.

Parameters
solversolver the multiplexer will attach to.
callbacksa vector of callbacks.

References roboptim::callback::Multiplexer< S >::attach().

template<typename S >
roboptim::callback::Multiplexer< S >::~Multiplexer ( )
virtual

Virtual destructor.

Member Function Documentation

template<typename S >
void roboptim::callback::Multiplexer< S >::attach ( )
protected

Register the multiplexer with the solver.

References roboptim::bind().

Referenced by roboptim::callback::Multiplexer< S >::Multiplexer().

template<typename S >
Multiplexer< S >::solverCallbacks_t & roboptim::callback::Multiplexer< S >::callbacks ( )

Return the vector of callbacks.

Returns
vector of callbacks.
template<typename S >
const Multiplexer< S >::solverCallbacks_t & roboptim::callback::Multiplexer< S >::callbacks ( ) const

Return the vector of callbacks.

Returns
vector of callbacks.
template<typename S >
void roboptim::callback::Multiplexer< S >::perIterationCallbackUnsafe ( const problem_t pb,
solverState_t state 
)
protectedvirtual

Meta-callback calling multiple callbacks.

Unsafe version that can throw exceptions.

Parameters
pbproblem.
statesolver state.
template<typename S >
std::ostream & roboptim::callback::Multiplexer< S >::print ( std::ostream &  o) const
virtual

Display the callback on the specified output stream.

Parameters
ooutput stream used for display.
Returns
output stream.

Reimplemented from roboptim::SolverCallback< S >.

References roboptim::decindent(), roboptim::iendl(), and roboptim::incindent().

template<typename S >
void roboptim::callback::Multiplexer< S >::unregister ( )
protected

Unregister the multiplexer from the solver.