0026936: Drawbacks of inlining in new type system in OCCT 7.0 -- automatic
[occt.git] / src / Message / Message_ProgressSentry.hxx
CommitLineData
42cf5bc1 1// Created on: 2002-02-22
2// Created by: Andrey BETENEV
3// Copyright (c) 2002-2014 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#ifndef _Message_ProgressSentry_HeaderFile
17#define _Message_ProgressSentry_HeaderFile
18
19#include <Standard.hxx>
20#include <Standard_DefineAlloc.hxx>
21#include <Standard_Handle.hxx>
22
23#include <Standard_Boolean.hxx>
24#include <Standard_CString.hxx>
25#include <Standard_Real.hxx>
26class Message_ProgressIndicator;
27class TCollection_HAsciiString;
28
29
30//! This class is a tool allowing to manage opening/closing
31//! scopes in the ProgressIndicator in convenient and safe way.
32//!
33//! Its main features are:
34//! - Set all parameters for the current scale on the given
35//! ProgressIndicator and open a new scope at one line
36//! - Iterator-like interface to opening next scopes and
37//! check for user break
38//! - Automatic scope closing in destructor
39//! - Safe for NULL ProgressIndicator (just does nothing)
40class Message_ProgressSentry
41{
42public:
43
44 DEFINE_STANDARD_ALLOC
45
46
47 Standard_EXPORT Message_ProgressSentry(const Handle(Message_ProgressIndicator)& PI, const Standard_CString name, const Standard_Real min, const Standard_Real max, const Standard_Real step, const Standard_Boolean isInf = Standard_False, const Standard_Real newScopeSpan = 0.0);
48
49 //! Creates an instance of ProgressSentry attaching it to
50 //! the specified ProgressIndicator, selects parameters of
51 //! the current scale, and opens a new scope with specified
52 //! span (equal to step by default)
53 Standard_EXPORT Message_ProgressSentry(const Handle(Message_ProgressIndicator)& PI, const Handle(TCollection_HAsciiString)& name, const Standard_Real min, const Standard_Real max, const Standard_Real step, const Standard_Boolean isInf = Standard_False, const Standard_Real newScopeSpan = 0.0);
54
55 //! Moves progress indicator to the end of the current scale
56 //! and relieves sentry from its duty. Methods other than Show()
57 //! will do nothing after this one is called.
58 void Relieve();
59~Message_ProgressSentry()
60{
61 Relieve();
62}
63
64 void Next (const Standard_CString name = 0) const;
65
66 void Next (const Standard_Real span, const Standard_CString name = 0) const;
67
68 //! Closes current scope and opens next one
69 //! with either specified or default span
70 void Next (const Standard_Real span, const Handle(TCollection_HAsciiString)& name) const;
71
72 //! Returns False if ProgressIndicator signals UserBreak
73 Standard_Boolean More() const;
74
75 //! Forces update of progress indicator display
76 void Show() const;
77
78
79
80
81protected:
82
83
84
85
86
87private:
88
89
90
91 Handle(Message_ProgressIndicator) myProgress;
92 Standard_Boolean myActive;
93
94
95};
96
97
98#include <Message_ProgressSentry.lxx>
99
100
101
102
103
104#endif // _Message_ProgressSentry_HeaderFile