herwig is hosted by Hepforge, IPPP Durham
Herwig 7.3.0
Progress.h
1// -*- C++ -*-
2//
3// Progress.h is a part of Herwig - A multi-purpose Monte Carlo event generator
4//
5
6// boost progress.hpp header file ------------------------------------------//
7
8// Copyright Beman Dawes 1994-99. Distributed under the Boost
9// Software License, Version 1.0. (See accompanying file
10// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
11
12// See http://www.boost.org/libs/timer for documentation.
13
14// Revision History
15
16// 2017-10-14 Modified for Herwig (D. Grellscheid)
17
18// 1 Dec 01 Add leading progress display strings (suggested by Toon Knapen)
19// 20 May 01 Introduce several static_casts<> to eliminate warning messages
20// (Fixed by Beman, reported by Herve Bronnimann)
21// 12 Jan 01 Change to inline implementation to allow use without library
22// builds. See docs for more rationale. (Beman Dawes)
23// 22 Jul 99 Name changed to .hpp
24// 16 Jul 99 Second beta
25// 6 Jul 99 Initial boost version
26
27#ifndef HERWIG_PROGRESS_H
28#define HERWIG_PROGRESS_H
29
30#include <iosfwd> // for ostream, cout, etc
31#include <string> // for string
32
33namespace Herwig {
34
35// progress_display --------------------------------------------------------//
36
37// progress_display displays an appropriate indication of
38// progress at an appropriate place in an appropriate form.
39
40// NOTE: (Jan 12, 2001) Tried to change unsigned long to boost::uintmax_t, but
41// found some compilers couldn't handle the required conversion to double.
42// Reverted to unsigned long until the compilers catch up.
43
45{
46 public:
47 explicit progress_display( unsigned long expected_count,
48 std::ostream & os,
49 const std::string & s1 = "\n", //leading strings
50 const std::string & s2 = "",
51 const std::string & s3 = "" );
52 progress_display( const progress_display& ) = delete;
53 progress_display& operator=( const progress_display& ) = delete;
54 void restart( unsigned long expected_count );
55
56 unsigned long operator+=( unsigned long increment );
57
58 unsigned long operator++() { return operator+=( 1 ); }
59 unsigned long count() const { return _count; }
60 unsigned long expected_count() const { return _expected_count; }
61
62 private:
63 std::ostream & m_os; // may not be present in all imps
64 const std::string m_s1; // string is more general, safer than
65 const std::string m_s2; // const char *, and efficiency or size are
66 const std::string m_s3; // not issues
67
68 unsigned long _count, _expected_count, _next_tic_count;
69 unsigned int _tic;
70 void display_tic();
71};
72
73} // namespace Herwig
74
75#endif // HERWIG_PROGRESS_H
-*- C++ -*-