1 // boost/chrono/stopwatches/stopwatch_reporter.hpp
2 // Copyright 2011 Vicente J. Botet Escriba
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or
5 // copy at http://www.boost.org/LICENSE_1_0.txt)
6 // See http://www.boost.org/libs/chrono/stopwatches for documentation.
8 #ifndef BOOST_CHRONO_STOPWATCHES_REPORTERS_STOPWATCH_REPORTER_HPP
9 #define BOOST_CHRONO_STOPWATCHES_REPORTERS_STOPWATCH_REPORTER_HPP
11 #include <boost/chrono/config.hpp>
13 #if !defined(BOOST_ENABLE_WARNINGS) && !defined(BOOST_CHRONO_ENABLE_WARNINGS)
15 #pragma GCC system_header
16 #elif defined __SUNPRO_CC
18 #elif defined _MSC_VER
19 #pragma warning(push, 1)
23 #include <boost/chrono/stopwatches/reporters/stopwatch_reporter_default_formatter.hpp>
24 #include <boost/chrono/stopwatches/stopwatch_scoped.hpp>
25 #include <boost/chrono/stopwatches/dont_start.hpp>
26 #include <boost/chrono/chrono.hpp>
27 #include <boost/chrono/detail/system.hpp>
28 #include <boost/cstdint.hpp>
36 template<class CharT, class Stopwatch, class Formatter=basic_stopwatch_reporter_default_formatter<CharT, Stopwatch> >
37 class basic_stopwatch_reporter: public Stopwatch
40 typedef Stopwatch base_type;
41 typedef typename Stopwatch::clock clock;
42 typedef Stopwatch stopwatch_type;
43 typedef Formatter formatter_type;
45 basic_stopwatch_reporter() BOOST_NOEXCEPT :
46 formatter_(), reported_(false)
50 #if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
51 explicit basic_stopwatch_reporter(system::error_code & ec) :
52 base_type(ec), formatter_(), reported_(false)
57 explicit basic_stopwatch_reporter(
58 const dont_start_t& tag
61 formatter_(), reported_(false)
65 explicit basic_stopwatch_reporter(const typename Formatter::char_type* fmt) :
66 formatter_(fmt), reported_(false)
69 explicit basic_stopwatch_reporter(typename Formatter::string_type const& fmt) :
70 formatter_(fmt), reported_(false)
73 explicit basic_stopwatch_reporter(formatter_type fmt) :
74 formatter_(fmt), reported_(false)
78 ~basic_stopwatch_reporter() BOOST_NOEXCEPT
86 inline void report() BOOST_NOEXCEPT
91 // inline void report(system::error_code & ec)
93 // formatter_(*this, ec);
102 formatter_type& format()
108 formatter_type formatter_;
111 basic_stopwatch_reporter(const basic_stopwatch_reporter&); // = delete;
112 basic_stopwatch_reporter& operator=(const basic_stopwatch_reporter&); // = delete;
116 template<class Stopwatch,
117 class Formatter = typename basic_stopwatch_reporter_default_formatter<char, Stopwatch>::type>
118 class stopwatch_reporter;
120 template<class Stopwatch, class Formatter>
121 struct basic_stopwatch_reporter_default_formatter<char, stopwatch_reporter<Stopwatch, Formatter> >
123 typedef Formatter type;
126 template<class Stopwatch, class Formatter>
127 class stopwatch_reporter: public basic_stopwatch_reporter<char, Stopwatch,
130 typedef basic_stopwatch_reporter<char, Stopwatch, Formatter> base_type;
132 typedef typename Stopwatch::clock clock;
133 typedef Stopwatch stopwatch_type;
134 typedef Formatter formatter_type;
140 #if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
141 explicit stopwatch_reporter(system::error_code & ec) :
146 explicit stopwatch_reporter(
147 const dont_start_t& tag
153 explicit stopwatch_reporter(formatter_type const& fmt) :
158 explicit stopwatch_reporter(const typename Formatter::char_type* fmt) :
162 explicit stopwatch_reporter(typename Formatter::string_type const& fmt) :
166 typedef stopwatch_runner<stopwatch_reporter<Stopwatch, Formatter> >
168 typedef stopwatch_stopper<stopwatch_reporter<Stopwatch, Formatter> >
170 typedef stopwatch_suspender<stopwatch_reporter<Stopwatch, Formatter> >
172 typedef stopwatch_resumer<stopwatch_reporter<Stopwatch, Formatter> >
177 stopwatch_reporter(const stopwatch_reporter&); // = delete;
178 stopwatch_reporter& operator=(const stopwatch_reporter&); // = delete;
181 template<class Stopwatch,
182 class Formatter = typename basic_stopwatch_reporter_default_formatter<wchar_t,
184 class wstopwatch_reporter;
186 template<class Stopwatch, class Formatter>
187 struct basic_stopwatch_reporter_default_formatter<wchar_t, wstopwatch_reporter<Stopwatch, Formatter> >
189 typedef Formatter type;
192 template<class Stopwatch, class Formatter>
193 class wstopwatch_reporter: public basic_stopwatch_reporter<wchar_t, Stopwatch, Formatter>
195 typedef basic_stopwatch_reporter<wchar_t, Stopwatch, Formatter> base_type;
197 typedef typename Stopwatch::clock clock;
198 typedef Stopwatch stopwatch_type;
199 typedef Formatter formatter_type;
201 wstopwatch_reporter() :
205 #if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
206 explicit wstopwatch_reporter(system::error_code & ec) :
211 explicit wstopwatch_reporter(
212 const dont_start_t& tag
218 explicit wstopwatch_reporter(formatter_type const& fmt) :
222 explicit wstopwatch_reporter(const typename Formatter::char_type* fmt) :
226 explicit wstopwatch_reporter(typename Formatter::string_type const& fmt) :
230 typedef stopwatch_runner<wstopwatch_reporter<Stopwatch, Formatter> >
232 typedef stopwatch_stopper<wstopwatch_reporter<Stopwatch, Formatter> >
234 typedef stopwatch_suspender<wstopwatch_reporter<Stopwatch, Formatter> >
236 typedef stopwatch_resumer<wstopwatch_reporter<Stopwatch, Formatter> >
241 wstopwatch_reporter(const wstopwatch_reporter&); // = delete;
242 wstopwatch_reporter& operator=(const wstopwatch_reporter&); // = delete;
245 } // namespace chrono
249 #if !defined(BOOST_ENABLE_WARNINGS) && !defined(BOOST_CHRONO_ENABLE_WARNINGS)
250 #if defined __SUNPRO_CC
252 #elif defined _MSC_VER