Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/boost/statechart/exception_translator.hpp @ 35

Last change on this file since 35 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 1.5 KB
Line 
1#ifndef BOOST_STATECHART_EXCEPTION_TRANSLATOR_HPP_INCLUDED
2#define BOOST_STATECHART_EXCEPTION_TRANSLATOR_HPP_INCLUDED
3//////////////////////////////////////////////////////////////////////////////
4// Copyright 2002-2006 Andreas Huber Doenni
5// Distributed under the Boost Software License, Version 1.0. (See accompany-
6// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7//////////////////////////////////////////////////////////////////////////////
8
9
10
11#include <boost/statechart/event.hpp>
12#include <boost/statechart/result.hpp>
13
14
15
16namespace boost
17{
18namespace statechart
19{
20
21
22
23//////////////////////////////////////////////////////////////////////////////
24class exception_thrown : public event< exception_thrown > {};
25
26
27
28//////////////////////////////////////////////////////////////////////////////
29template< class ExceptionEvent = exception_thrown >
30class exception_translator
31{
32  public:
33    //////////////////////////////////////////////////////////////////////////
34    // The following declarations should be private.
35    // They are only public because many compilers lack template friends.
36    //////////////////////////////////////////////////////////////////////////
37    template< class Action, class ExceptionEventHandler >
38    result operator()( Action action, ExceptionEventHandler eventHandler )
39    {
40      try
41      {
42        return action();
43      }
44      catch ( ... )
45      {
46        return eventHandler( ExceptionEvent() );
47      }
48    }
49};
50
51
52
53} // namespace statechart
54} // namespace boost
55
56
57
58#endif
Note: See TracBrowser for help on using the repository browser.