Boost.Test > Components > The Execution Monitor > boost::execution_monitor

# boost::execution_monitor

boost::execution_monitor uniformly detects and reports the occurrence of several types of signals and exceptions, reducing various errors to a uniform boost::execution_exception which is returned to a caller.

    class execution_monitor {
    public:
        virtual     ~execution_monitor();

        template<typename Exception, typename ExceptionTranslator>
        void        register_exception_translator( ExceptionTranslator const& tr, boost::type<Exception>* = 0 );

        int         execute( bool catch_system_errors = true, int timeout = 0 );

        virtual int function() = 0;

    }; // exception monitor

### execution_monitor::~execution_monitor()

Supplied cause this class intended to be used polymorphically.

### execution_monitor::register_exception_translator( ExceptionTranslator const& tr, boost::type<Exception>* )

Use this template member function to register translator for any custom exceptions types of your choice. Translators gets chained, so you could register as many as you want. Translator function of functor should accept single parameter - const reference to the instance of the class Exception. The return value is ignored. An example usage is like this:

the_monitor.register_exception_translator<my_exception1>( translate_my_exception1 )

### execution_monitor::execute( bool catch_system_errors, int timeout )

Effects:

Calls the execution_monitor::function() inside a try/catch block which may also include other unspecified platform dependent error detection code. Throws boost::execution_exception on an uncaught C++ exception, timeout alarm and, if catch_system_errors flag is true, a hardware or software signal, trap, or other exception. If catch_system_errors flag is false program will crash in case of system level error occur. execution_monitor::execute() doesn't consider it an error for the execution_monitor::function() to return a non-zero value.

Returns:

The integer value returned by the execution_monitor::function().

### execution_monitor::function()

User supplied function to monitor.